Skip to content

robot-simulator: encode position as object instead of string #936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 125 additions & 32 deletions exercises/robot-simulator/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"exercise": "robot-simulator",
"version": "1.0.0",
"version": "2.0.0",
"comments": [
"Some tests have two expectations: one for the position, one for the direction",
"Optionally, you can also test",
Expand All @@ -16,23 +16,35 @@
"description": "Robots are created with a position and direction",
"property": "create",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
}
},
{
"description": "Negative positions are allowed",
"property": "create",
"robot": {
"position": "(-1,-1)",
"position": {
"x": -1,
"y": -1
},
"direction": "south"
},
"expected": {
"position": "(-1,-1)",
"position": {
"x": -1,
"y": -1
},
"direction": "south"
}
}
Expand All @@ -45,18 +57,27 @@
"description": "does not change the position",
"property": "turnRight",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
"position": "(0,0)"
"position": {
"x": 0,
"y": 0
}
}
},
{
"description": "changes the direction from north to east",
"property": "turnRight",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
Expand All @@ -67,7 +88,10 @@
"description": "changes the direction from east to south",
"property": "turnRight",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "east"
},
"expected": {
Expand All @@ -78,7 +102,10 @@
"description": "changes the direction from south to west",
"property": "turnRight",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "south"
},
"expected": {
Expand All @@ -89,7 +116,10 @@
"description": "changes the direction from west to north",
"property": "turnRight",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "west"
},
"expected": {
Expand All @@ -105,18 +135,27 @@
"description": "does not change the position",
"property": "turnLeft",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
"position": "(0,0)"
"position": {
"x": 0,
"y": 0
}
}
},
{
"description": "changes the direction from north to west",
"property": "turnLeft",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
Expand All @@ -127,7 +166,10 @@
"description": "changes the direction from west to south",
"property": "turnLeft",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "west"
},
"expected": {
Expand All @@ -138,7 +180,10 @@
"description": "changes the direction from south to east",
"property": "turnLeft",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "south"
},
"expected": {
Expand All @@ -149,7 +194,10 @@
"description": "changes the direction from east to north",
"property": "turnLeft",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "east"
},
"expected": {
Expand All @@ -165,7 +213,10 @@
"description": "does not change the direction",
"property": "advance",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
Expand All @@ -176,44 +227,68 @@
"description": "increases the y coordinate one when facing north",
"property": "advance",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"expected": {
"position": "(0,1)"
"position": {
"x": 0,
"y": 1
}
}
},
{
"description": "decreases the y coordinate by one when facing south",
"property": "advance",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "south"
},
"expected": {
"position": "(0,-1)"
"position": {
"x": 0,
"y": -1
}
}
},
{
"description": "increases the x coordinate by one when facing east",
"property": "advance",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "east"
},
"expected": {
"position": "(1,0)"
"position": {
"x": 1,
"y": 0
}
}
},
{
"description": "decreases the x coordinate by one when facing west",
"property": "advance",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "west"
},
"expected": {
"position": "(-1,0)"
"position": {
"x": -1,
"y": 0
}
}
}
]
Expand All @@ -225,38 +300,56 @@
"description": "instructions to move west and north",
"property": "instructions",
"robot": {
"position": "(0,0)",
"position": {
"x": 0,
"y": 0
},
"direction": "north"
},
"instructions": "LAAARALA",
"expected": {
"position": "(-4,1)",
"position": {
"x": -4,
"y": 1
},
"direction": "west"
}
},
{
"description": "instructions to move west and south",
"property": "instructions",
"robot": {
"position": "(2,-7)",
"position": {
"x": 2,
"y": -7
},
"direction": "east"
},
"instructions": "RRAAAAALA",
"expected": {
"position": "(-3,-8)",
"position": {
"x": -3,
"y": -8
},
"direction": "south"
}
},
{
"description": "instructions to move east and north",
"property": "instructions",
"robot": {
"position": "(8,4)",
"position": {
"x": 8,
"y": 4
},
"direction": "south"
},
"instructions": "LAAARRRALLLL",
"expected": {
"position": "(11,5)",
"position": {
"x": 11,
"y": 5
},
"direction": "north"
}
}
Expand Down