def test_composite_semantic_type(self): Foo = semantic.SemanticType('Foo', field_names=['a', 'b']) A = semantic.SemanticType('A', variant_of=Foo.field['a']) B = semantic.SemanticType('B', variant_of=Foo.field['b']) self.assertTrue(semantic.is_semantic_type(A)) self.assertTrue(semantic.is_semantic_type(B)) self.assertTrue(semantic.is_semantic_type(Foo[A, B]))
def test_simple_semantic_type(self): A = semantic.SemanticType('A') X = semantic.SemanticType('X') Foo = semantic.SemanticType('Foo', field_names=['a', 'b']) self.assertTrue(semantic.is_semantic_type(A)) self.assertTrue(semantic.is_semantic_type(X)) self.assertTrue(semantic.is_semantic_type(Foo))
def test_union_type_expr(self): # If this test fails, then the hiearchy has been rearranged and the # properties tested for `UnionTypeExpression` should be tested for # this class. # - Your Friendly Dead Man's Switch X = semantic.SemanticType('X') Y = semantic.SemanticType('Y') self.assertIsInstance(X | Y, grammar.UnionTypeExpression) self.assertIsInstance(semantic._SemanticUnionType([X, Y]), grammar.UnionTypeExpression)
def test_composite_type(self): # If this test fails, then the hiearchy has been rearranged and the # properties tested for `TypeExpression` should be tested for # this class. # - Your Friendly Dead Man's Switch self.assertIsInstance(semantic.SemanticType('X'), grammar.TypeExpression) self.assertIsInstance(semantic._SemanticType('X', variant_of=()), grammar.TypeExpression)
def test_composite_type(self): # If this test fails, then the hiearchy has been rearranged and the # properties tested for `CompositeType` should be tested for # this class. # - Your Friendly Dead Man's Switch self.assertIsInstance(semantic.SemanticType('X', field_names='foo'), grammar.CompositeType) self.assertIsInstance( semantic._IncompleteSemanticType('X', field_names=('foo',), field_members={'foo': ()}, variant_of=()), grammar.CompositeType)