454 lines
8.1 KiB
JSON
454 lines
8.1 KiB
JSON
{
|
|
"function": "turn",
|
|
"cases": [
|
|
{
|
|
"name": "turn-normal-perpendicular",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
"Up"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Up",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-same-direction-is-fine",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
"Right"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-reverse-rejected",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
"Left"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-replaces-pending-turn",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Up",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
"Down"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Down",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-against-last-moved-dir",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Up",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
"Left"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Up",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-ignored-when-paused",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
},
|
|
"Up"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-ignored-when-game-over",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "GameOver",
|
|
"frame": 0
|
|
},
|
|
"Up"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "GameOver",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-ignored-when-won",
|
|
"args": [
|
|
{
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Won",
|
|
"frame": 0
|
|
},
|
|
"Up"
|
|
],
|
|
"expected": {
|
|
"width": 5,
|
|
"height": 5,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 2
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 2
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Won",
|
|
"frame": 0
|
|
}
|
|
}
|
|
]
|
|
}
|