349 lines
6.2 KiB
JSON
349 lines
6.2 KiB
JSON
{
|
|
"function": "update",
|
|
"cases": [
|
|
{
|
|
"name": "tick-moves-the-snake",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Tick"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "tick-eating-respawns-apple",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Tick"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 1,
|
|
"y": 1
|
|
},
|
|
"seed": 1831565813,
|
|
"score": 1,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "tick-into-wall-is-game-over",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 0,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Tick"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 2,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 0,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "GameOver",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "tick-while-paused-does-nothing",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Tick"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-sets-next-dir",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Turn",
|
|
"dir": "Down"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Down",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-against-direction-is-ignored",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Turn",
|
|
"dir": "Left"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "turn-while-paused-is-ignored",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
},
|
|
{
|
|
"tag": "Turn",
|
|
"dir": "Down"
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
}
|
|
}
|
|
]
|
|
}
|