|
| 1 | +func test_create_robot_at_origin_facing_north(robot): |
| 2 | + robot.position = Vector2i(0, 0) |
| 3 | + robot.direction = "north" |
| 4 | + var result = [robot.position, robot.direction] |
| 5 | + var expected = [Vector2i(0, 0), "north"] |
| 6 | + return [expected, result] |
| 7 | + |
| 8 | + |
| 9 | +func test_create_robot_at_negative_position_facing_south(robot): |
| 10 | + robot.position = Vector2i(-1, -1) |
| 11 | + robot.direction = "south" |
| 12 | + var result = [robot.position, robot.direction] |
| 13 | + var expected = [Vector2i(-1, -1), "south"] |
| 14 | + return [expected, result] |
| 15 | + |
| 16 | + |
| 17 | +func test_rotating_clockwise_changes_north_to_east(robot): |
| 18 | + robot.position = Vector2i(0, 0) |
| 19 | + robot.direction = "north" |
| 20 | + robot.move("R") |
| 21 | + var result = [robot.position, robot.direction] |
| 22 | + var expected = [Vector2i(0, 0), "east"] |
| 23 | + return [expected, result] |
| 24 | + |
| 25 | + |
| 26 | +func test_rotating_clockwise_changes_east_to_south(robot): |
| 27 | + robot.position = Vector2i(0, 0) |
| 28 | + robot.direction = "east" |
| 29 | + robot.move("R") |
| 30 | + var result = [robot.position, robot.direction] |
| 31 | + var expected = [Vector2i(0, 0), "south"] |
| 32 | + return [expected, result] |
| 33 | + |
| 34 | + |
| 35 | +func test_rotating_clockwise_changes_south_to_west(robot): |
| 36 | + robot.position = Vector2i(0, 0) |
| 37 | + robot.direction = "south" |
| 38 | + robot.move("R") |
| 39 | + var result = [robot.position, robot.direction] |
| 40 | + var expected = [Vector2i(0, 0), "west"] |
| 41 | + return [expected, result] |
| 42 | + |
| 43 | + |
| 44 | +func test_rotating_clockwise_changes_west_to_north(robot): |
| 45 | + robot.position = Vector2i(0, 0) |
| 46 | + robot.direction = "west" |
| 47 | + robot.move("R") |
| 48 | + var result = [robot.position, robot.direction] |
| 49 | + var expected = [Vector2i(0, 0), "north"] |
| 50 | + return [expected, result] |
| 51 | + |
| 52 | + |
| 53 | +func test_rotating_counterclockwise_changes_north_to_west(robot): |
| 54 | + robot.position = Vector2i(0, 0) |
| 55 | + robot.direction = "north" |
| 56 | + robot.move("L") |
| 57 | + var result = [robot.position, robot.direction] |
| 58 | + var expected = [Vector2i(0, 0), "west"] |
| 59 | + return [expected, result] |
| 60 | + |
| 61 | + |
| 62 | +func test_rotating_counterclockwise_changes_west_to_south(robot): |
| 63 | + robot.position = Vector2i(0, 0) |
| 64 | + robot.direction = "west" |
| 65 | + robot.move("L") |
| 66 | + var result = [robot.position, robot.direction] |
| 67 | + var expected = [Vector2i(0, 0), "south"] |
| 68 | + return [expected, result] |
| 69 | + |
| 70 | + |
| 71 | +func test_rotating_counterclockwise_changes_south_to_east(robot): |
| 72 | + robot.position = Vector2i(0, 0) |
| 73 | + robot.direction = "south" |
| 74 | + robot.move("L") |
| 75 | + var result = [robot.position, robot.direction] |
| 76 | + var expected = [Vector2i(0, 0), "east"] |
| 77 | + return [expected, result] |
| 78 | + |
| 79 | + |
| 80 | +func test_rotating_counterclockwise_changes_east_to_north(robot): |
| 81 | + robot.position = Vector2i(0, 0) |
| 82 | + robot.direction = "east" |
| 83 | + robot.move("L") |
| 84 | + var result = [robot.position, robot.direction] |
| 85 | + var expected = [Vector2i(0, 0), "north"] |
| 86 | + return [expected, result] |
| 87 | + |
| 88 | + |
| 89 | +func test_moving_forward_one_facing_north_increments_y(robot): |
| 90 | + robot.position = Vector2i(0, 0) |
| 91 | + robot.direction = "north" |
| 92 | + robot.move("A") |
| 93 | + var result = [robot.position, robot.direction] |
| 94 | + var expected = [Vector2i(0, 1), "north"] |
| 95 | + return [expected, result] |
| 96 | + |
| 97 | + |
| 98 | +func test_moving_forward_one_facing_south_decrements_y(robot): |
| 99 | + robot.position = Vector2i(0, 0) |
| 100 | + robot.direction = "south" |
| 101 | + robot.move("A") |
| 102 | + var result = [robot.position, robot.direction] |
| 103 | + var expected = [Vector2i(0, -1), "south"] |
| 104 | + return [expected, result] |
| 105 | + |
| 106 | + |
| 107 | +func test_moving_forward_one_facing_east_increments_x(robot): |
| 108 | + robot.position = Vector2i(0, 0) |
| 109 | + robot.direction = "east" |
| 110 | + robot.move("A") |
| 111 | + var result = [robot.position, robot.direction] |
| 112 | + var expected = [Vector2i(1, 0), "east"] |
| 113 | + return [expected, result] |
| 114 | + |
| 115 | + |
| 116 | +func test_moving_forward_one_facing_west_decrements_x(robot): |
| 117 | + robot.position = Vector2i(0, 0) |
| 118 | + robot.direction = "west" |
| 119 | + robot.move("A") |
| 120 | + var result = [robot.position, robot.direction] |
| 121 | + var expected = [Vector2i(-1, 0), "west"] |
| 122 | + return [expected, result] |
| 123 | + |
| 124 | + |
| 125 | +func test_moving_east_and_north_from_readme(robot): |
| 126 | + robot.position = Vector2i(7, 3) |
| 127 | + robot.direction = "north" |
| 128 | + robot.move("RAALAL") |
| 129 | + var result = [robot.position, robot.direction] |
| 130 | + var expected = [Vector2i(9, 4), "west"] |
| 131 | + return [expected, result] |
| 132 | + |
| 133 | + |
| 134 | +func test_moving_west_and_north(robot): |
| 135 | + robot.position = Vector2i(0, 0) |
| 136 | + robot.direction = "north" |
| 137 | + robot.move("LAAARALA") |
| 138 | + var result = [robot.position, robot.direction] |
| 139 | + var expected = [Vector2i(-4, 1), "west"] |
| 140 | + return [expected, result] |
| 141 | + |
| 142 | + |
| 143 | +func test_moving_west_and_south(robot): |
| 144 | + robot.position = Vector2i(2, -7) |
| 145 | + robot.direction = "east" |
| 146 | + robot.move("RRAAAAALA") |
| 147 | + var result = [robot.position, robot.direction] |
| 148 | + var expected = [Vector2i(-3, -8), "south"] |
| 149 | + return [expected, result] |
| 150 | + |
| 151 | + |
| 152 | +func test_moving_east_and_north(robot): |
| 153 | + robot.position = Vector2i(8, 4) |
| 154 | + robot.direction = "south" |
| 155 | + robot.move("LAAARRRALLLL") |
| 156 | + var result = [robot.position, robot.direction] |
| 157 | + var expected = [Vector2i(11, 5), "north"] |
| 158 | + return [expected, result] |
0 commit comments