feat(scala): m01–m06 port with shared fixtures
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
045029639e
commit
1e186733d1
23 files changed
+771
-2
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package snake
|
||||
|
||||
import Fixtures.*
|
||||
|
||||
class M05GameSuite extends munit.FunSuite:
|
||||
cases("m05-update").foreach { c =>
|
||||
test(s"update: ${c("name").str}") {
|
||||
val a = c("args")
|
||||
assertEquals(Game.update(gameState(a(0)), action(a(1))), gameState(c("expected")))
|
||||
}
|
||||
}
|
||||
|
||||
cases("m05-replay").foreach { c =>
|
||||
test(s"replay: ${c("name").str}") {
|
||||
val a = c("args")
|
||||
assertEquals(Game.replay(gameState(a(0)), list(a(1))(action)), gameState(c("expected")))
|
||||
}
|
||||
}
|
||||
|
||||
cases("m05-history").foreach { c =>
|
||||
test(s"history: ${c("name").str}") {
|
||||
val a = c("args")
|
||||
assertEquals(Game.history(gameState(a(0)), list(a(1))(action)), list(c("expected"))(gameState))
|
||||
}
|
||||
}
|
||||
|
||||
private val replayArgs = cases("m05-replay")(0)("args")
|
||||
private val start = gameState(replayArgs(0))
|
||||
private val actions = list(replayArgs(1))(action)
|
||||
|
||||
test("history has one more state than there are actions") {
|
||||
assertEquals(Game.history(start, actions).length, actions.length + 1)
|
||||
}
|
||||
|
||||
test("history starts at the start state and ends where replay ends") {
|
||||
val states = Game.history(start, actions)
|
||||
assertEquals(states.head, start)
|
||||
assertEquals(states.last, Game.replay(start, actions))
|
||||
}
|
||||
Reference in new issue
Block a user