Datasets:
Download scripts/test_export.py from Theohhh/minif2f-lean4: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/datasets/Theohhh/minif2f-lean4/resolve/main/scripts/test_export.py
- Command line
-
hf download hf://datasets/Theohhh/minif2f-lean4/scripts/test_export.py
-
curl -L -o test_export.py https://huggingface.co/datasets/Theohhh/minif2f-lean4/resolve/main/scripts/test_export.py
1.28 kB
| """Offline tests for rejecting source changes the exporter cannot safely parse.""" | |
| import unittest | |
| from export import parse_source | |
| HEADER = "import Mathlib\n\nset_option maxHeartbeats 0\n\nopen BigOperators Real Nat Topology Rat\n\n" | |
| SOURCE = (HEADER + "theorem example_1 (n : ℕ) : n = n := by sorry\n").encode("utf-8") | |
| class ParseSourceTest(unittest.TestCase): | |
| def test_preserves_unicode_and_exact_source(self): | |
| row = parse_source("MiniF2F/Test/example_1.lean", SOURCE) | |
| self.assertEqual((row["header"] + row["formal_statement"]).encode("utf-8"), SOURCE) | |
| self.assertEqual(row["id"], "example_1") | |
| def test_rejects_ambiguous_or_changed_source(self): | |
| mutations = [ | |
| SOURCE.replace(b"by sorry", b"by rfl"), | |
| SOURCE + b"theorem second : True := by sorry\n", | |
| SOURCE.replace(b"n = n", b"n = (by sorry)"), | |
| SOURCE + b"#eval 1\n", | |
| SOURCE.replace(b"import Mathlib", b"import Other"), | |
| SOURCE.replace(b"example_1", b"different_name"), | |
| ] | |
| for source in mutations: | |
| with self.subTest(source=source), self.assertRaises(ValueError): | |
| parse_source("MiniF2F/Test/example_1.lean", source) | |
| if __name__ == "__main__": | |
| unittest.main() | |