feat(fsharp): m01-m06 util, model, rules, random, spawn, game, view with Expecto tests
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
183821737e
commit
9cbefeb2be
@@ -0,0 +1,33 @@
|
||||
module Snake.Tests.M05Game
|
||||
|
||||
open Expecto
|
||||
open Snake
|
||||
open Snake.Tests.Fixtures
|
||||
|
||||
let private replayCase () = List.head (cases "m05-replay")
|
||||
let private start () = gameState (arg 0 (replayCase ()))
|
||||
let private actions () = list action (arg 1 (replayCase ()))
|
||||
|
||||
[<Tests>]
|
||||
let tests =
|
||||
testList "M05 Game" [
|
||||
yield! fixtureTests "m05-update" "update" (fun c ->
|
||||
Expect.equal (Game.update (gameState (arg 0 c)) (action (arg 1 c))) (gameState (expected c)) "update")
|
||||
|
||||
yield! fixtureTests "m05-replay" "replay" (fun c ->
|
||||
Expect.equal (Game.replay (gameState (arg 0 c)) (list action (arg 1 c))) (gameState (expected c)) "replay")
|
||||
|
||||
yield! fixtureTests "m05-history" "history" (fun c ->
|
||||
Expect.equal
|
||||
(Game.history (gameState (arg 0 c)) (list action (arg 1 c)))
|
||||
(list gameState (expected c))
|
||||
"history")
|
||||
|
||||
testCase "history has one more state than there are actions" (fun () ->
|
||||
Expect.equal (List.length (Game.history (start ()) (actions ()))) (List.length (actions ()) + 1) "length")
|
||||
|
||||
testCase "history starts at the start state and ends where replay ends" (fun () ->
|
||||
let states = Game.history (start ()) (actions ())
|
||||
Expect.equal (List.head states) (start ()) "first"
|
||||
Expect.equal (List.last states) (Game.replay (start ()) (actions ())) "last")
|
||||
]
|
||||
Reference in New Issue
Block a user