forked from turingschool-examples/code_retreat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobot_test.rb
More file actions
159 lines (131 loc) · 2.97 KB
/
robot_test.rb
File metadata and controls
159 lines (131 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'simulator'
class RobotTurningTest < MiniTest::Unit::TestCase
def robot
@robot
end
def setup
@robot = Robot.new
end
def test_robot_bearing
[:east, :west, :north, :south].each do |direction|
robot.orient(direction)
assert_equal direction, robot.bearing
end
end
def test_invalid_robot_bearing
skip
assert_raises ArgumentError do
robot.orient(:crood)
end
end
def test_turn_right_from_north
skip
robot.orient(:north)
robot.turn_right
assert_equal :east, robot.bearing
end
def test_turn_right_from_east
skip
# Implement me
end
def test_turn_right_from_south
skip
# Implement me
end
def test_turn_right_from_west
skip
# Implement me
end
def test_turn_left_from_north
skip
# Implement me
end
def test_turn_left_from_east
skip
# Implement me
end
def test_turn_left_from_south
skip
# Implement me
end
def test_turn_left_from_west
skip
# Implement me
end
def test_robot_coordinates
skip
robot.at(3, 0)
assert_equal [3, 0], robot.coordinates
end
def test_other_robot_coordinates
skip
robot.at(-2, 5)
assert_equal [-2, 5], robot.coordinates
end
def test_advance_when_facing_north
skip
robot.at(0,0)
robot.orient(:north)
robot.advance
assert_equal [0, 1], robot.coordinates
end
def test_advance_when_facing_east
skip
# Implement me
end
def test_advance_when_facing_south
skip
# Implement me
end
def test_advance_when_facing_west
skip
# Implement me
end
end
class RobotSimulatorTest < MiniTest::Unit::TestCase
def simulator
@simulator ||= Simulator.new
end
def test_instructions_for_turning_left
skip
assert_equal [:turn_left], simulator.instructions("L")
end
def test_instructions_for_turning_right
skip
# Implement me
end
def test_instructions_for_advancing
skip
# Implement me
end
def test_series_of_instructions
skip
commands = [:turn_right, :advance, :advance, :turn_left]
assert_equal commands, simulator.instructions("RAAL")
end
def test_instruct_robot
skip
robot = Robot.new
simulator.place(robot, x: -2, y: 1, direction: :east)
simulator.evaluate(robot, "RLAALAL")
assert_equal [0,2], robot.coordinates
# Also check the robot bearing
end
def test_instruct_many_robots
skip
robot1 = Robot.new
robot2 = Robot.new
robot3 = Robot.new
simulator.place(robot1, x: 0, y: 0, direction: :north)
simulator.place(robot2, x: 2, y: -7, direction: :east)
simulator.place(robot3, x: 8, y: 4, direction: :south)
simulator.evaluate(robot1, "LAAARALA")
simulator.evaluate(robot2, "RRAAAAALA")
simulator.evaluate(robot3, "LAAARRRALLLL")
# Check Robot 1 coordinates and bearing
# Check Robot 2 coordinates and bearing
# Check Robot 3 coordinates and bearing
end
end