From db293f3606a97b3e417de27124858e134005acbd Mon Sep 17 00:00:00 2001 From: Anonymous Authors Date: Fri, 24 Jul 2026 13:24:36 -0500 Subject: Add minimal GAP reproduction package --- tests/test_surface.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/test_surface.py (limited to 'tests/test_surface.py') diff --git a/tests/test_surface.py b/tests/test_surface.py new file mode 100644 index 0000000..78c4d5e --- /dev/null +++ b/tests/test_surface.py @@ -0,0 +1,43 @@ +from __future__ import annotations + +import pytest + +from gap_pipeline.surface import ( + apply_rename_map, + create_surface_variant, + validate_rename_map, +) + + +def test_math_only_rename_preserves_english_article(item) -> None: + text = r"Let \(a\) be a randomly chosen value with \(a>0\)." + renamed = apply_rename_map(text, {"a": "coefalpha"}) + assert renamed == ( + r"Let \(coefalpha\) be a randomly chosen value with \(coefalpha>0\)." + ) + + +def test_surface_variant_changes_problem_and_solution(item) -> None: + variant = create_surface_variant( + item, + "descriptive_long", + {"a": "positiveScalar"}, + ) + assert "positiveScalar" in variant.problem + assert "positiveScalar" in variant.solution + assert "Let positiveScalar" not in variant.problem + + +def test_collision_and_nonbijection_are_rejected(item) -> None: + with pytest.raises(ValueError, match="collides"): + validate_rename_map( + {"a": "a"}, + existing_identifiers=["a"], + scientific_constants=[], + ) + with pytest.raises(ValueError, match="one-to-one"): + validate_rename_map( + {"a": "sharedName", "b": "sharedName"}, + existing_identifiers=["a", "b"], + scientific_constants=[], + ) -- cgit v1.2.3