Esempio n. 1
0
 def testSemantic1(self):
     util.semanticProgram(
         util.source('''
             class NineTest:
                 pass
         ''')
     )
Esempio 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)
Esempio n. 3
0
    def testVirtualOverrideKeywords1(self):
        program = util.source('''
            class A_Class:
                override def Bork():
                    pass
        ''')

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

        self.failUnlessRaises(
            error.SyntaxError,
            lambda: util.semanticProgram(program)
        )
Esempio 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)
        )
Esempio 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)
        )
Esempio 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)
        )
Esempio 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
Esempio 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)
        )