"""Regression checks for the reference coverage guard.""" import unittest from check_reference import REFERENCE, check, operation_names class ReferenceCheckTest(unittest.TestCase): @classmethod def setUpClass(cls): cls.document = REFERENCE.read_text() def test_current_reference(self): self.assertEqual(check(self.document), []) def test_missing_operation(self): document = self.document.replace('
', '
') self.assertIn("Missing operation: spat.graph_compute", check(document)) def test_duplicate_id(self): document = self.document + '
' self.assertIn("Duplicate HTML id: spat.graph_compute", check(document)) def test_empty_semantics(self): prefix, marker, article = self.document.partition('
') document = prefix + marker + article.replace('data-field="semantics"', 'data-unused="semantics"', 1) self.assertIn("spat.graph_compute: missing/empty semantics", check(document)) def test_broken_links(self): errors = check(self.document + 'badbad') self.assertIn("Broken fragment: #missing", errors) self.assertIn("Broken local link: missing.cpp", errors) def test_stale_operation(self): document = self.document.replace('id="spat.graph_compute"', 'id="spat.removed"') self.assertIn("Unknown/stale operation: spat.removed", check(document)) def test_inherited_operation_definitions(self): source = ''' class Plan : SpatOp; class Compute : Plan; def Example : Compute<"example">; def LayoutAttr : EnumAttr; // def Removed : SpatOp<"removed">; ''' self.assertEqual(operation_names([source]), {"spat.example"}) if __name__ == "__main__": unittest.main()