def testParameter(self):
        program = util.source('''
            def foo(c as System.Type):
                pass
        ''')

        util.buildProgram('namespace_parameter_test', program, ['mscorlib'])
    def testReturnType(self):
        program = util.source('''
            def multiply(x as int, y as int) as int:
                pass
        ''')

        util.buildProgram('functiondecl_returntype_test', program)
    def testEmptyInterface(self):
        program = util.source('''
            interface Foo:
                pass
        ''')

        util.buildProgram('interface_empty_test', program)
    def testCodeGen(self):
        program = util.source('''
            def foo(x as int, y as int):
                print x * y
        ''')

        util.buildProgram('functiondecl_codegen_test', program)
    def testReturnType(self):
        program = util.source('''
            def foo() as System.Object:
                pass
        ''')

        util.buildProgram('namespace_return_test', program, ['mscorlib'])
    def testValue(self):
        program = util.source('''
            var t as System.Reflection.Assembly
            print t
        ''')

        util.buildProgram('namespace_variable_test', program, ['mscorlib'])
    def testBuildInterface(self):
        program = util.source('''
            interface TestIface:
                def foo() as int
                def bar(a as int)
                def baz(b as string) as string
        ''')

        util.buildProgram('interface_build_test', program)
    def testBuildLibrary(self):
        program = util.source('''
            class LibraryClass:
                def SayHi():
                    print 'Hi!'
        ''')

        util.buildProgram('build_library_test.dll', program)

        self.assertTrue(os.path.exists('bin/build_library_test.dll'))
 def testBlockScopeGlobal(self):
     # Make sure that globals can be declared inside block statements
     program = util.source('''
         var count = 10
         while count > 0:
             count -= 1
             
             var x = count
             print x
     ''')
     util.buildProgram('vardecl_block_scope_global_test', program)
    def testImplementInterface(self):
        program = util.source('''
            interface Firable:
                def fire() as void

            class Employee(Firable):
                def fire() as void:
                    print 'Firing employee!'

            class Missle(Firable):
                def fire() as void:
                    print 'Initiating thermonuclear war with China for fun and profit.'
        ''')

        util.buildProgram('interface_implement_test', program)
    def testDuplicate(self):
        program = 'var x\nvar x'

        self.failUnlessRaises(
            error.SyntaxError,
            lambda: util.buildProgram('vardecl_duplicate_test', program)
        )
Beispiel #12
0
    def testAttributeCodeGeneration(self):
        program = util.source('''
            class X:
                [TestClass.Thingie]
                pass
        ''')

        util.buildProgram('attribute_code_generation_test', program, ['bin/ClassLibrary1'])

        # Load the resulting executable and check that the attribute is there
        from System import String
        from System.Reflection import Assembly

        program = Assembly.Load(String('bin/attribute_code_generation_test'))
        x = program.GetType('X')

        attrs = [a for a in x.GetCustomAttributes(False) if 'Thingie' in a.GetType().FullName]
        self.assertNotEqual(0, len(attrs))
Beispiel #13
0
    def testFailResolveOverload(self):
        program = util.source('''
            var o = TestClass.TestClass(2)
            o.Method(o)
        ''')

        self.assertRaises(
            error.TypeError,
            lambda: util.buildProgram('extern_overload_fail_test', program, ['mscorlib', 'bin/ClassLibrary1'])
        )
    def testDuplicateIdentifier(self):
        program = util.source('''
            def foo():
                print 9

            var foo = 9
        ''')

        self.failUnlessRaises(
            error.SyntaxError,
            lambda: util.buildProgram('functiondecl_duplicate_test', program)
        )
    def testArgCountMismatch(self):
        program = util.source('''
            def foo(x as int, y as int):
                print x * y

            foo(3)
        ''')

        self.failUnlessRaises(
            error.SyntaxError,
            lambda: util.buildProgram('functioncall_argcountmismatch_test', program)
        )
    def testTypeMismatch(self):
        program = util.source('''
            def foo(x as string):
                print x

            foo(9)
        ''')

        self.failUnlessRaises(
            error.TypeError,
            lambda: util.buildProgram('functioncall_typemismatch_test', program)
        )
    def testIncompleteInterface(self):
        program = util.source('''
            interface Duck:
                def quack() as void

            class Foo(Duck):
                pass
        ''')

        self.assertRaises(
            error.OverrideError,
            lambda: util.buildProgram('interface_incomplete_test', program)
        )
Beispiel #18
0
    def testIncompleteExternalInterface(self):
        program = util.source('''
            class MyClass(TestClass.ExternalInterface):
                def Foo():
                    print 'Foo!'

            var o as TestClass.ExternalInterface
            o = MyClass()
            o.Foo()
        ''')

        self.assertRaises(
            error.OverrideError,
            lambda: util.buildProgram('incomplete_external_interface_test', program, ['bin/ClassLibrary1'])
        )
    def testCodeGen(self):
        program = util.source('''
            5+2
        ''')

        util.buildProgram('expression_statement_test', program)
    def testCodeGen(self):
        program = util.source('''
            var x = System.Object()
        ''')

        result = util.buildProgram('ctorcall_test', program, ['mscorlib'])