当前位置: 首页>>代码示例>>Python>>正文


Python util.source函数代码示例

本文整理汇总了Python中tests.util.source函数的典型用法代码示例。如果您正苦于以下问题:Python source函数的具体用法?Python source怎么用?Python source使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了source函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testModifiers3

    def testModifiers3(self):
        program = util.source('''
            sealed override def bork():
                pass
        ''')

        util.parseProgram(program)
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:functiondecltest.py

示例2: testModifiers1

    def testModifiers1(self):
        program = util.source('''
            static def bork():
                pass
        ''')

        util.parseProgram(program)
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:functiondecltest.py

示例3: testReadProperty

    def testReadProperty(self):
        program = util.source('''
            var o = TestClass.TestClass(2)
            print o.Property
        ''')

        util.runProgram('extern_read_property_test', program, ['mscorlib', 'bin/ClassLibrary1'])
开发者ID:andyfriesen,项目名称:nine,代码行数:7,代码来源:externtest.py

示例4: testCompileString

    def testCompileString(self):
        program = util.source('''
            print 'Expect 9:'
            var count = 0
            if 1<9:
                count = count + 1
            else:
                count = count + 99

            if 1>9:
                pass
            else:
                count = count + 3

            if 1>9:
                pass
            elif 9>1:
                count = count + 4

            if 9<1:
                pass
            elif 9<1:
                pass
            else:
                count = count + 1

            print count

            if count == 9:
                print 'Looks like it passed.  Woohoo!'
            else:
                print 'Oh no it failed!!' ''')

        util.runProgram('if_test',program)
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:34,代码来源:iftest.py

示例5: testRandomCharTests

    def testRandomCharTests(self):
        # TODO:when this is all implemented this test should reflect that
        from tests import util

        program = util.source(
            """
            #var z as char='N' #char
            var y = '9' #string
            var x = "nine" #also string
            var z = y[0]
            
            #print "z = 'N':"
            #print z
            print "x = 'nine' starts with 'n':"
            print x
            print x[0]
            #print "see 'n' become 'N':"
            x[0]=z
            print x
            print "see three '9's:"
            print y
            print y[0]
            print y as char
        """
        )

        self.assertRaises(error.TypeError, lambda: util.runProgram("test_random_char_tests", program))
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:27,代码来源:literaltest.py

示例6: testParseNoExceptOrFinally

    def testParseNoExceptOrFinally(self):
        program = util.source('''
            try:
                pass
        ''')

        self.assertRaises(error.SyntaxError, lambda: util.parseProgram(program))
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:trytest.py

示例7: testEmitCode

    def testEmitCode(self):
        program = util.source('''\
            var x as int
            print x
        ''')

        util.runProgram('variable_test', program, ['mscorlib'])
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:variabletest.py

示例8: testCodeGen

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

        util.buildProgram('functiondecl_codegen_test', program)
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:functiondecltest.py

示例9: testEmptyInterface

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

        util.buildProgram('interface_empty_test', program)
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:interfacetest.py

示例10: testReadAttribute

    def testReadAttribute(self):
        program = util.source('''
            var o = TestClass.TestClass()
            print o.x
        ''')

        util.runProgram('extern_read_attr_test', program, ['bin/ClassLibrary1'])
开发者ID:andyfriesen,项目名称:nine,代码行数:7,代码来源:externtest.py

示例11: testReturnType

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

        util.buildProgram('namespace_return_test', program, ['mscorlib'])
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:namespacetest.py

示例12: testTypes

 def testTypes(self):
     util.runProgram('print_types', util.source('''
         print (27 as int)
         print (27 as float)
         print (27 as System.Double)
         print (true as boolean)
     '''), ['mscorlib'])
开发者ID:andyfriesen,项目名称:nine,代码行数:7,代码来源:printtest.py

示例13: testValue

    def testValue(self):
        program = util.source('''
            var t as System.Reflection.Assembly
            print t
        ''')

        util.buildProgram('namespace_variable_test', program, ['mscorlib'])
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:7,代码来源:namespacetest.py

示例14: testCodeGen

    def testCodeGen(self):
        program = util.source('''
            var a = -9
            var b = -3.1415926535897931
            var c = +9
            var d = -c
            var e = ~0
            var f = ~(~1)

            print a
            print b
            print c
            print d
            print e
            print f

            var t1 = true
            var f1 = false
            var f2 = not t1
            var t2 = not f2
            var t3 = not f1

            print ''
            print 'Expect True, False, False, True, True'
            print t1
            print f1
            print f2
            print t2
            print t3
        ''')

        util.runProgram('unary_codegen_test', program)
开发者ID:andyfriesen,项目名称:nine,代码行数:32,代码来源:unarytest.py

示例15: testIndentation

    def testIndentation(self):
        result = lex(util.source('''
            0
                4

                4
                    8

            0
              2
                  6'''))

        EOS = END_OF_STATEMENT
        BB = BEGIN_BLOCK
        EB = END_BLOCK
        EOF = END_OF_FILE

        expected = [
            '0', EOS,  BB, '4',  EOS, '4', EOS,
             BB, '8', EOS,  EB,   EB, EOS, '0', EOS,
             BB, '2', EOS,  BB,  '6', EOS,  EB,  EB, EOS, EOF
        ]

        self.failUnlessEqual(len(result), len(expected))
        self.failUnlessEqual(result, expected)
开发者ID:BackupTheBerlios,项目名称:nine-svn,代码行数:25,代码来源:lexertest.py


注:本文中的tests.util.source函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。