@@ -20,146 +20,128 @@ fn positions_can_be_negative() {
20
20
#[ test]
21
21
#[ ignore]
22
22
fn turning_right_does_not_change_position ( ) {
23
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
24
- robot. turn_right ( ) ;
23
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . turn_right ( ) ;
25
24
assert_eq ! ( ( 0 , 0 ) , robot. position( ) ) ;
26
25
}
27
26
28
27
#[ test]
29
28
#[ ignore]
30
29
fn turning_right_from_north_points_the_robot_east ( ) {
31
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
32
- robot. turn_right ( ) ;
30
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . turn_right ( ) ;
33
31
assert_eq ! ( Direction :: East , robot. direction( ) ) ;
34
32
}
35
33
36
34
#[ test]
37
35
#[ ignore]
38
36
fn turning_right_from_east_points_the_robot_south ( ) {
39
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: East ) ;
40
- robot. turn_right ( ) ;
37
+ let robot = Robot :: new ( 0 , 0 , & Direction :: East ) . turn_right ( ) ;
41
38
assert_eq ! ( Direction :: South , robot. direction( ) ) ;
42
39
}
43
40
44
41
#[ test]
45
42
#[ ignore]
46
43
fn turning_right_from_south_points_the_robot_west ( ) {
47
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: South ) ;
48
- robot. turn_right ( ) ;
44
+ let robot = Robot :: new ( 0 , 0 , & Direction :: South ) . turn_right ( ) ;
49
45
assert_eq ! ( Direction :: West , robot. direction( ) ) ;
50
46
}
51
47
52
48
#[ test]
53
49
#[ ignore]
54
50
fn turning_right_from_west_points_the_robot_north ( ) {
55
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: West ) ;
56
- robot. turn_right ( ) ;
51
+ let robot = Robot :: new ( 0 , 0 , & Direction :: West ) . turn_right ( ) ;
57
52
assert_eq ! ( Direction :: North , robot. direction( ) ) ;
58
53
}
59
54
60
55
#[ test]
61
56
#[ ignore]
62
57
fn turning_left_does_not_change_position ( ) {
63
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
64
- robot. turn_left ( ) ;
58
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . turn_left ( ) ;
65
59
assert_eq ! ( ( 0 , 0 ) , robot. position( ) ) ;
66
60
}
67
61
68
62
#[ test]
69
63
#[ ignore]
70
64
fn turning_left_from_north_points_the_robot_west ( ) {
71
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
72
- robot. turn_left ( ) ;
65
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . turn_left ( ) ;
73
66
assert_eq ! ( Direction :: East , robot. direction( ) ) ;
74
67
}
75
68
76
69
#[ test]
77
70
#[ ignore]
78
71
fn turning_left_from_west_points_the_robot_south ( ) {
79
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: East ) ;
80
- robot. turn_left ( ) ;
72
+ let robot = Robot :: new ( 0 , 0 , & Direction :: East ) . turn_left ( ) ;
81
73
assert_eq ! ( Direction :: South , robot. direction( ) ) ;
82
74
}
83
75
84
76
#[ test]
85
77
#[ ignore]
86
78
fn turning_left_from_south_points_the_robot_east ( ) {
87
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: South ) ;
88
- robot. turn_left ( ) ;
79
+ let robot = Robot :: new ( 0 , 0 , & Direction :: South ) . turn_left ( ) ;
89
80
assert_eq ! ( Direction :: East , robot. direction( ) ) ;
90
81
}
91
82
92
83
#[ test]
93
84
#[ ignore]
94
85
fn turning_left_from_east_points_the_robot_north ( ) {
95
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: East ) ;
96
- robot. turn_left ( ) ;
86
+ let robot = Robot :: new ( 0 , 0 , & Direction :: East ) . turn_left ( ) ;
97
87
assert_eq ! ( Direction :: North , robot. direction( ) ) ;
98
88
}
99
89
100
90
#[ test]
101
91
#[ ignore]
102
92
fn advance_does_not_change_the_direction ( ) {
103
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
104
- robot. advance ( ) ;
93
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . advance ( ) ;
105
94
assert_eq ! ( Direction :: North , robot. direction( ) ) ;
106
95
}
107
96
108
97
#[ test]
109
98
#[ ignore]
110
99
fn advance_increases_the_y_coordinate_by_one_when_facing_north ( ) {
111
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
112
- robot. advance ( ) ;
100
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . advance ( ) ;
113
101
assert_eq ! ( ( 0 , 1 ) , robot. position( ) ) ;
114
102
}
115
103
116
104
#[ test]
117
105
#[ ignore]
118
106
fn advance_decreases_the_y_coordinate_by_one_when_facing_south ( ) {
119
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: South ) ;
120
- robot. advance ( ) ;
107
+ let robot = Robot :: new ( 0 , 0 , & Direction :: South ) . advance ( ) ;
121
108
assert_eq ! ( ( 0 , -1 ) , robot. position( ) ) ;
122
109
}
123
110
124
111
#[ test]
125
112
#[ ignore]
126
113
fn advance_increases_the_x_coordinate_by_one_when_facing_east ( ) {
127
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: East ) ;
128
- robot. advance ( ) ;
114
+ let robot = Robot :: new ( 0 , 0 , & Direction :: East ) . advance ( ) ;
129
115
assert_eq ! ( ( 1 , 0 ) , robot. position( ) ) ;
130
116
}
131
117
132
118
#[ test]
133
119
#[ ignore]
134
120
fn advance_decreases_the_x_coordinate_by_one_when_facing_west ( ) {
135
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: West ) ;
136
- robot. advance ( ) ;
121
+ let robot = Robot :: new ( 0 , 0 , & Direction :: West ) . advance ( ) ;
137
122
assert_eq ! ( ( -1 , 0 ) , robot. position( ) ) ;
138
123
}
139
124
140
125
#[ test]
141
126
#[ ignore]
142
127
fn follow_instructions_to_move_west_and_north ( ) {
143
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: North ) ;
144
- robot. instructions ( "LAAARALA" ) ;
128
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . instructions ( "LAAARALA" ) ;
145
129
assert_eq ! ( ( -4 , 1 ) , robot. position( ) ) ;
146
130
assert_eq ! ( Direction :: West , robot. direction( ) ) ;
147
131
}
148
132
149
133
#[ test]
150
134
#[ ignore]
151
135
fn follow_instructions_to_move_west_and_south ( ) {
152
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: East ) ;
153
- robot. instructions ( "RRAAAAALA" ) ;
136
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . instructions ( "RRAAAAALA" ) ;
154
137
assert_eq ! ( ( -3 , -8 ) , robot. position( ) ) ;
155
138
assert_eq ! ( Direction :: South , robot. direction( ) ) ;
156
139
}
157
140
158
141
#[ test]
159
142
#[ ignore]
160
143
fn follow_instructions_to_move_east_and_north ( ) {
161
- let mut robot = Robot :: new ( 0 , 0 , & Direction :: South ) ;
162
- robot. instructions ( "LAAARRRALLLL" ) ;
144
+ let robot = Robot :: new ( 0 , 0 , & Direction :: North ) . instructions ( "LAAARRRALLLL" ) ;
163
145
assert_eq ! ( ( 11 , 5 ) , robot. position( ) ) ;
164
146
assert_eq ! ( Direction :: North , robot. direction( ) ) ;
165
147
}
0 commit comments