Exemplo n.º 1
0
 def testSemantic1(self):
     util.semanticProgram(
         util.source('''
             class NineTest:
                 pass
         ''')
     )
Exemplo n.º 2
0
    def testVirtualOverrideKeywords3(self):
        program = util.source('''
            class A_Class:
                virtual def Method():
                    pass
            class B_Class(A_Class):
                override def Method():
                    pass
        ''')

        util.semanticProgram(program)
Exemplo n.º 3
0
    def testVirtualOverrideKeywords1(self):
        program = util.source('''
            class A_Class:
                override def Bork():
                    pass
        ''')

        self.assertRaises(
            error.OverrideError,
            lambda: util.semanticProgram(program)
        )
Exemplo n.º 4
0
    def testSemantic2(self):
        program = util.source('''
            class NineTest:
                var x
                def Method():
                    pass
        ''')

        self.failUnlessRaises(
            error.SyntaxError,
            lambda: util.semanticProgram(program)
        )
Exemplo n.º 5
0
    def testCircularInheritance(self):
        program = util.source('''
            class A(B):
                pass

            class B(A):
                pass
        ''')

        self.assertRaises(
            error.CircularInheritanceError,
            lambda: util.semanticProgram(program)
        )
Exemplo n.º 6
0
    def testSemantic3(self):
        program = util.source('''
            class DuplicateName:
                pass

            class DuplicateName:
                var x
                def Method():
                    pass
        ''')

        self.failUnlessRaises(
            error.NameError,
            lambda: util.semanticProgram(program)
        )
Exemplo n.º 7
0
    def testVirtualOverrideKeywords2(self):
        program = util.source('''
            class A_Class:
                override def Method():
                    pass
            class B_Class(A_Class):
                override def Method(x as int):
                    pass
            '''
        )

        self.assertRaises(
            error.OverrideError,
            lambda: util.semanticProgram(program)
        )
Exemplo n.º 8
0
    def testGetMethod(self):
        "testGetMethod: Test ClassDecl.getMethod()"
        from ast import vartypes

        program = util.source('''
            class A_Class:
                virtual def Method():
                    pass

            class B_Class(A_Class):
                override def Method():
                    pass
        ''')

        result = util.semanticProgram(program).pop()
        assert isinstance(result, ClassDecl)

        assert result.getMethod("Method", (), vartypes.VoidType) is not None
Exemplo n.º 9
0
    def testSealedMethod(self):
        program = util.source('''
            class A:
                virtual def Method():
                    print 'A'

            class B(A):
                sealed override def Method():
                    print 'B'

            class C(B):
                override def Method():
                    print 'C'
        ''')

        self.assertRaises(
            error.OverrideError,
            lambda: util.semanticProgram(program)
        )