chore(js): polish pong keys, held mapping and m09 main test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
3146bb630a
commit
59bece5443
+12
-4
@@ -1,12 +1,12 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { states, classicActions, render, main, TICK_MS } from '../src/app.js'
|
||||
import { run, map as mapStream } from '../src/stream.js'
|
||||
import { trace, map as mapIO, randomSeed } from '../src/io.js'
|
||||
import { run } from '../src/stream.js'
|
||||
import { trace } from '../src/io.js'
|
||||
import { view } from '../src/view.js'
|
||||
import { newGame } from '../src/spawn.js'
|
||||
import { Action } from '../src/model.js'
|
||||
import { freeze } from './helpers.js'
|
||||
import { freeze, classicMain } from './helpers.js'
|
||||
|
||||
const time = (t) => ({ tag: 'Time', t })
|
||||
const down = (key) => ({ tag: 'KeyDown', key })
|
||||
@@ -42,7 +42,6 @@ test('m09 main asks for a random seed, then builds the stream from it', () => {
|
||||
|
||||
// `main` itself switches to speedActions in m10, so the 150 ms behaviour is checked on the same program built from classicActions.
|
||||
test('m09 the program built from classicActions draws the new game first, then the ticked game after 150 ms', () => {
|
||||
const classicMain = mapIO(randomSeed, (seed) => mapStream(states(seed, classicActions), render))
|
||||
const { result: stream } = trace(classicMain, 42)
|
||||
const [first, next] = stream.step(time(0))
|
||||
const [second] = next.step(time(150))
|
||||
@@ -50,3 +49,12 @@ test('m09 the program built from classicActions draws the new game first, then t
|
||||
assert.equal(second.length, 1)
|
||||
assert.notDeepEqual(trace(second[0], 0).ops, trace(first[0], 0).ops)
|
||||
})
|
||||
|
||||
// Holds before and after m10: whatever `main` ticks with, the clock must be wired in, so time passing produces more drawings.
|
||||
test('m09 main draws again once time has passed', () => {
|
||||
const { result: stream } = trace(main, 42)
|
||||
const [first, next] = stream.step(time(0))
|
||||
const [later] = next.step(time(150))
|
||||
assert.equal(first.length, 1)
|
||||
assert.ok(later.length >= 1)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user