- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`) - ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk" for every build stat); Stats.base uses stats_field_name - ludic.shooter: compare aim modes and fire patterns with AimMode.* and WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y - ludic.npcai: DecisionMade / brain_set_state use AiState.* - examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and BACKDROP named; strings.ludic header says what it prints - whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only), `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every ```ludic fence reformatted with the fixed formatter (whitespace only) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
51 lines
1.3 KiB
Text
51 lines
1.3 KiB
Text
# coverage.ludic — a spec built to be measured by `bin/x test --coverage` (issue
|
|
# #45). Compiled with `--coverage`, every statement bumps a per-source-line hit
|
|
# counter; at exit the counts are dumped and `bin/x test --coverage` turns them
|
|
# into a per-file line-coverage report.
|
|
#
|
|
# The tests below exercise `sign` fully but only the taken branches of `grade`,
|
|
# so the report flags `grade`'s unreached line — the whole point of coverage:
|
|
# it shows you the branch your tests forgot.
|
|
#
|
|
# As an ordinary spec it still passes and prints:
|
|
# == 3 passed, 0 failed ==
|
|
program CoverageSpec {
|
|
# fully covered: the tests below hit all three returns.
|
|
function sign(n: int) -> int {
|
|
if n > 0 {
|
|
return 1
|
|
}
|
|
if n < 0 {
|
|
return -1
|
|
}
|
|
return 0
|
|
}
|
|
|
|
# partially covered: no test passes a score below 60, so the `return 0` (fail)
|
|
# line is never reached and shows up as uncovered in the report.
|
|
function grade(score: int) -> int {
|
|
if score >= 90 {
|
|
return 4
|
|
}
|
|
if score >= 60 {
|
|
return 2
|
|
}
|
|
return 0
|
|
}
|
|
|
|
test "sign covers every branch" {
|
|
expect_eq(sign(7), 1)
|
|
expect_eq(sign(-3), -1)
|
|
expect_eq(sign(0), 0)
|
|
}
|
|
|
|
test "grade: high scores" {
|
|
expect_eq(grade(95), 4)
|
|
expect_eq(grade(75), 2)
|
|
}
|
|
|
|
test "grade: boundary" {
|
|
expect_eq(grade(90), 4)
|
|
expect_eq(grade(60), 2)
|
|
}
|
|
}
|