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


Python utils.compare函数代码示例

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


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

示例1: test_as

 def test_as(self):
     src = """
     def test():
         with foo as bar:
             x + y
     """
     expected = """
     def test():
         mgr__U0 = foo
         exit__U0 = type(mgr__U0).__exit__
         value__U0 = type(mgr__U0).__enter__(mgr__U0)
         exc__U0 = True
         try:
             try:
                 bar = value__U0
                 x + y
             except:
                 exc__U0 = False
                 if not exit__U0(mgr__U0, *sys.exc_info()):
                     raise
         finally:
             if exc__U0:
                 exit__U0(mgr__U0, None, None, None)
     """
     utils.compare(src, expected, dewith.DeWith)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:25,代码来源:test_dewith.py

示例2: test_for_break_continue

 def test_for_break_continue(self):
     src = """
     def test():
         for a in b:
             if a:
                 break
             if b:
                 continue
             print "hi"
     """
     expected = """
     def test():
         interrupted__U0 = "0_none"
         for a in b:
             interrupted__U0 = "0_none"
             if a:
                 interrupted__U0 = "2_break"
             if interrupted__U0 == "0_none":
                 interrupted__U0 = "0_none"
                 if b:
                     interrupted__U0 = "1_continue"
                 if interrupted__U0 == "0_none":
                     print "hi"
             if interrupted__U0 == "1_continue":
                 interrupted__U0 = "0_none"
             if ((interrupted__U0 == '2_break') or (interrupted__U0 == '3_return')):
                 break
         if interrupted__U0 == "2_break":
             interrupted__U0 = "0_none"
         return None
     """
     utils.compare(src, expected, DeInterrupt)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:32,代码来源:test_deinterrupt.py

示例3: test_tryfinally

 def test_tryfinally(self):
     src = """
     def test():
         try:
             return "hi"
         finally:
             return "hello"
         print "world"
     """
     expected = """
     def test():
         returnvalue__U0 = None
         interrupted__U0 = "0_none"
         try:
             returnvalue__U0 = "hi"
             interrupted__U0 = "3_return"
         finally:
             interrupted__U1 = interrupted__U0
             returnvalue__U0 = "hello"
             interrupted__U0 = "3_return"
             interrupted__U0 = __pydron_max__(interrupted__U0, interrupted__U1)
         if interrupted__U0 == "0_none":
             print "world"
         return returnvalue__U0
     """
     utils.compare(src, expected, DeInterrupt)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:26,代码来源:test_deinterrupt.py

示例4: test_return_skip_nested

 def test_return_skip_nested(self):
     src = """
     def test():
         if a:
             if b:
                 return "Hello"
             print "a"
         print "b"
     """
     expected = """
     def test():
         returnvalue__U0 = None
         interrupted__U0 = "0_none"
         if a:
             interrupted__U0 = "0_none"
             if b:
                 returnvalue__U0 = 'Hello'
                 interrupted__U0 = '3_return'
             if interrupted__U0 == "0_none":
                 print "a"
         if interrupted__U0 == "0_none":
             print "b"
         return returnvalue__U0
     """
     utils.compare(src, expected, DeInterrupt)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:25,代码来源:test_deinterrupt.py

示例5: test_compare_oneop

 def test_compare_oneop(self):
     src = """
     test = a == b
     """
     expected = """
     test = a == b
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py

示例6: test_augassign_simple

 def test_augassign_simple(self):
     src = """
     x += "s"
     """
     expected = """
     x += "s"
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py

示例7: test_delete_single

 def test_delete_single(self):
     src = """
     del x[0]
     """
     expected = """
     del x[0]
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py

示例8: test_attr

 def test_attr(self):
     src = """
     x = a.y
     """
     expected = """
     x = a.y
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py

示例9: test_single_assignment

 def test_single_assignment(self):
     src = """
     x = 1
     """
     expected = """
     x = 1
     """
     utils.compare(src, expected, demultitarget.DeMultiTarget)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_demultitarget.py

示例10: test_locals_globals

 def test_locals_globals(self):
     src = """
     exec "code" in context, context2
     """
     expected = """
     __pydron_exec__("code", context2, context)
     """
     utils.compare(src, expected, deexec.DeExec)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_deexec.py

示例11: test_binop_single

 def test_binop_single(self):
     src = """
     x = 1 + 2
     """
     expected = """
     x = 1 + 2
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py

示例12: test_call_no_args

 def test_call_no_args(self):
     src = """
     f()
     """
     expected = """
     f()
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_decomplexexpr.py

示例13: test_exec

 def test_exec(self):
     src = """
     exec "code"
     """
     expected = """
     __pydron_exec__("code", locals(), globals())
     """
     utils.compare(src, expected, deexec.DeExec)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:8,代码来源:test_deexec.py

示例14: test_multi_assignment_num

 def test_multi_assignment_num(self):
     src = """
     x = y = 1
     """
     expected = """
     x = 1
     y = 1
     """
     utils.compare(src, expected, demultitarget.DeMultiTarget)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_demultitarget.py

示例15: test_augassign

 def test_augassign(self):
     src = """
     x += "s" + "t"
     """
     expected = """
     binop__U0 = "s" + "t"
     x += binop__U0
     """
     utils.compare(src, expected, decomplexexpr.DeComplexExpr)
开发者ID:istoney,项目名称:eucliddatasimulator,代码行数:9,代码来源:test_decomplexexpr.py


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