示例#1
0
    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]))
示例#2
0
    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))
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)