{ "function": "advance", "cases": [ { "name": "advance-plain-move", "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 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 3, "y": 2 }, { "x": 2, "y": 2 }, { "x": 1, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } }, { "name": "advance-moves-in-nextDir-and-records-it-as-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 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 1 }, { "x": 2, "y": 2 }, { "x": 1, "y": 2 } ], "dir": "Up", "nextDir": "Up", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } }, { "name": "advance-keeps-apple-it-did-not-reach", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 2 }, { "x": 1, "y": 2 }, { "x": 0, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": { "x": 4, "y": 4 }, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 3, "y": 2 }, { "x": 2, "y": 2 }, { "x": 1, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": { "x": 4, "y": 4 }, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } }, { "name": "advance-eat-grows-scores-clears-apple", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 2 }, { "x": 1, "y": 2 }, { "x": 0, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": { "x": 3, "y": 2 }, "seed": 1, "score": 4, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 3, "y": 2 }, { "x": 2, "y": 2 }, { "x": 1, "y": 2 }, { "x": 0, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": null, "seed": 1, "score": 5, "status": "Playing", "frame": 0 } }, { "name": "advance-into-wall-is-game-over", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 4, "y": 2 }, { "x": 3, "y": 2 }, { "x": 2, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 4, "y": 2 }, { "x": 3, "y": 2 }, { "x": 2, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": null, "seed": 1, "score": 0, "status": "GameOver", "frame": 0 } }, { "name": "advance-into-top-wall-records-turn", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 0 }, { "x": 2, "y": 1 }, { "x": 2, "y": 2 } ], "dir": "Up", "nextDir": "Up", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 0 }, { "x": 2, "y": 1 }, { "x": 2, "y": 2 } ], "dir": "Up", "nextDir": "Up", "apple": null, "seed": 1, "score": 0, "status": "GameOver", "frame": 0 } }, { "name": "advance-into-own-body-is-game-over", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 2 }, { "x": 3, "y": 2 }, { "x": 3, "y": 3 }, { "x": 2, "y": 3 }, { "x": 1, "y": 3 } ], "dir": "Left", "nextDir": "Down", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 2 }, { "x": 3, "y": 2 }, { "x": 3, "y": 3 }, { "x": 2, "y": 3 }, { "x": 1, "y": 3 } ], "dir": "Down", "nextDir": "Down", "apple": null, "seed": 1, "score": 0, "status": "GameOver", "frame": 0 } }, { "name": "advance-into-vacating-tail", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 1, "y": 1 }, { "x": 1, "y": 2 }, { "x": 2, "y": 2 }, { "x": 2, "y": 1 } ], "dir": "Up", "nextDir": "Right", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 2, "y": 1 }, { "x": 1, "y": 1 }, { "x": 1, "y": 2 }, { "x": 2, "y": 2 } ], "dir": "Right", "nextDir": "Right", "apple": null, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } }, { "name": "advance-into-tail-while-eating", "args": [ { "width": 5, "height": 5, "snake": [ { "x": 1, "y": 1 }, { "x": 1, "y": 2 }, { "x": 2, "y": 2 }, { "x": 2, "y": 1 } ], "dir": "Up", "nextDir": "Right", "apple": { "x": 2, "y": 1 }, "seed": 1, "score": 0, "status": "Playing", "frame": 0 } ], "expected": { "width": 5, "height": 5, "snake": [ { "x": 1, "y": 1 }, { "x": 1, "y": 2 }, { "x": 2, "y": 2 }, { "x": 2, "y": 1 } ], "dir": "Right", "nextDir": "Right", "apple": { "x": 2, "y": 1 }, "seed": 1, "score": 0, "status": "GameOver", "frame": 0 } }, { "name": "advance-paused-unchanged", "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": "Paused", "frame": 0 } ], "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": "Paused", "frame": 0 } }, { "name": "advance-game-over-unchanged", "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 } ], "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": "advance-won-unchanged", "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 } ], "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 } } ] }