From eb569f5a79234c5fed561799ff4ef44dc98ddec9 Mon Sep 17 00:00:00 2001 From: Philip Zhang Date: Tue, 11 Aug 2026 16:09:52 +0800 Subject: [PATCH] test: cover Java text blocks in error scanning --- tools/test_error_catalog.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/test_error_catalog.py b/tools/test_error_catalog.py index 9c0b8f9e..41d51549 100644 --- a/tools/test_error_catalog.py +++ b/tools/test_error_catalog.py @@ -139,6 +139,30 @@ class Sample { self.assertEqual([], discover(root)) + def test_discovery_ignores_text_blocks_and_character_literals(self): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + source = root / "sample/src/main/java/io/teaql/Sample.java" + source.parent.mkdir(parents=True) + source.write_text( + "class Sample {\n" + ' String example = """\n' + ' prefix "quoted" throw new TextBlockException("TEXT_BLOCK");\n' + ' """;\n' + " char quote = '\"';\n" + " void run() {\n" + ' throw new RealException("REAL");\n' + " }\n" + "}\n", + encoding="utf-8", + ) + + results = discover(root) + + self.assertEqual(1, len(results)) + self.assertEqual("RealException", results[0].exception) + self.assertEqual(7, results[0].line) + if __name__ == "__main__": unittest.main()