{ "exercise": "robot-simulator", "version": "2.0.0", "comments": [ "Some tests have two expectations: one for the position, one for the direction", "Optionally, you can also test", " - An invalid direction throws an error", " - An invalid instruction throws an error", " - Default starting position and direction if none are provided" ], "cases": [ { "description": "A robot is created with a position and a direction", "cases": [ { "description": "Robots are created with a position and direction", "property": "create", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "position": { "x": 0, "y": 0 }, "direction": "north" } }, { "description": "Negative positions are allowed", "property": "create", "robot": { "position": { "x": -1, "y": -1 }, "direction": "south" }, "expected": { "position": { "x": -1, "y": -1 }, "direction": "south" } } ] }, { "description": "rotates the robot's direction 90 degrees clockwise", "cases": [ { "description": "does not change the position", "property": "turnRight", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "position": { "x": 0, "y": 0 } } }, { "description": "changes the direction from north to east", "property": "turnRight", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "direction": "east" } }, { "description": "changes the direction from east to south", "property": "turnRight", "robot": { "position": { "x": 0, "y": 0 }, "direction": "east" }, "expected": { "direction": "south" } }, { "description": "changes the direction from south to west", "property": "turnRight", "robot": { "position": { "x": 0, "y": 0 }, "direction": "south" }, "expected": { "direction": "west" } }, { "description": "changes the direction from west to north", "property": "turnRight", "robot": { "position": { "x": 0, "y": 0 }, "direction": "west" }, "expected": { "direction": "north" } } ] }, { "description": "rotates the robot's direction 90 degrees counter-clockwise", "cases": [ { "description": "does not change the position", "property": "turnLeft", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "position": { "x": 0, "y": 0 } } }, { "description": "changes the direction from north to west", "property": "turnLeft", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "direction": "west" } }, { "description": "changes the direction from west to south", "property": "turnLeft", "robot": { "position": { "x": 0, "y": 0 }, "direction": "west" }, "expected": { "direction": "south" } }, { "description": "changes the direction from south to east", "property": "turnLeft", "robot": { "position": { "x": 0, "y": 0 }, "direction": "south" }, "expected": { "direction": "east" } }, { "description": "changes the direction from east to north", "property": "turnLeft", "robot": { "position": { "x": 0, "y": 0 }, "direction": "east" }, "expected": { "direction": "north" } } ] }, { "description": "moves the robot forward 1 space in the direction it is pointing", "cases": [ { "description": "does not change the direction", "property": "advance", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "direction": "north" } }, { "description": "increases the y coordinate one when facing north", "property": "advance", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "expected": { "position": { "x": 0, "y": 1 } } }, { "description": "decreases the y coordinate by one when facing south", "property": "advance", "robot": { "position": { "x": 0, "y": 0 }, "direction": "south" }, "expected": { "position": { "x": 0, "y": -1 } } }, { "description": "increases the x coordinate by one when facing east", "property": "advance", "robot": { "position": { "x": 0, "y": 0 }, "direction": "east" }, "expected": { "position": { "x": 1, "y": 0 } } }, { "description": "decreases the x coordinate by one when facing west", "property": "advance", "robot": { "position": { "x": 0, "y": 0 }, "direction": "west" }, "expected": { "position": { "x": -1, "y": 0 } } } ] }, { "description": "Where R = Turn Right, L = Turn Left and A = Advance, the robot can follow a series of instructions and end up with the correct position and direction", "cases": [ { "description": "instructions to move west and north", "property": "instructions", "robot": { "position": { "x": 0, "y": 0 }, "direction": "north" }, "instructions": "LAAARALA", "expected": { "position": { "x": -4, "y": 1 }, "direction": "west" } }, { "description": "instructions to move west and south", "property": "instructions", "robot": { "position": { "x": 2, "y": -7 }, "direction": "east" }, "instructions": "RRAAAAALA", "expected": { "position": { "x": -3, "y": -8 }, "direction": "south" } }, { "description": "instructions to move east and north", "property": "instructions", "robot": { "position": { "x": 8, "y": 4 }, "direction": "south" }, "instructions": "LAAARRRALLLL", "expected": { "position": { "x": 11, "y": 5 }, "direction": "north" } } ] } ] }