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]>
24 lines
785 B
Python
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
|