Files
isotope-typst/tests/test_evaluate.py
T
paultal 40145d1fce Measure correctness: bracket check and a 102-row tagged hand test (#12)
isotope-eval reports a balanced column next to exact and compiles, and breaks hand-test exact match down by category. eval/hand_test.jsonl grows from 32 to 102 tagged rows built from the stress-test failures in #2 and #4-#9.

Closes #3

Co-authored-by: Paul Tal <[email protected]>
2026-11-27 01:29:25 +02:00

24 lines
785 B
Python

import collections
from isotope_typst.evaluate import balanced, read_jsonl
from isotope_typst.validate import compiles_many
def test_balanced():
assert balanced("frac(sin(x), x)")
assert balanced("sum_(i = 1)^n i")
assert not balanced("(x + 1)^2 + 1)^2 + 1)^2")
assert not balanced("(-frac(b, 2)")
assert not balanced("x y z frac(x")
assert not balanced("(x]")
def test_hand_test_is_well_formed():
rows = read_jsonl("eval/hand_test.jsonl")
assert len(rows) >= 100
assert all(set(r) == {"en", "typ", "cat"} for r in rows)
assert all(balanced(r["typ"]) for r in rows)
assert all(compiles_many([r["typ"] for r in rows]))
dupes = [en for en, k in collections.Counter(r["en"] for r in rows).items() if k > 1]
assert not dupes, dupes