453 lines
8.1 KiB
JSON
453 lines
8.1 KiB
JSON
{
|
|
"function": "spawnApple",
|
|
"cases": [
|
|
{
|
|
"name": "spawn-picks-a-free-cell-and-advances-seed",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 0,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"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": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-other-seed-picks-other-cell",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 1,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 1831565814,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-with-one-free-cell",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 1
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 7,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 1
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 0,
|
|
"y": 1
|
|
},
|
|
"seed": 1831565820,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-on-full-board",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 1
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 1
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
{
|
|
"x": 1,
|
|
"y": 1
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 1
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Won",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-apple-present-unchanged",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": {
|
|
"x": 2,
|
|
"y": 1
|
|
},
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Playing",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-paused-unchanged",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Paused",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-gameover-unchanged",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "GameOver",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "GameOver",
|
|
"frame": 0
|
|
}
|
|
},
|
|
{
|
|
"name": "spawn-won-unchanged",
|
|
"args": [
|
|
{
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Won",
|
|
"frame": 0
|
|
}
|
|
],
|
|
"expected": {
|
|
"width": 3,
|
|
"height": 2,
|
|
"snake": [
|
|
{
|
|
"x": 1,
|
|
"y": 0
|
|
},
|
|
{
|
|
"x": 0,
|
|
"y": 0
|
|
}
|
|
],
|
|
"dir": "Right",
|
|
"nextDir": "Right",
|
|
"apple": null,
|
|
"seed": 5,
|
|
"score": 0,
|
|
"status": "Won",
|
|
"frame": 0
|
|
}
|
|
}
|
|
]
|
|
}
|