示例#1
0
 def test_list_comprehension_is_transformed_as_with_generator_expression_but_wrapped_in_list_call(self):
     _assert_transform(
         nodes.list_comprehension(
             nodes.ref("y"),
             nodes.ref("x"),
             nodes.ref("xs")
         ),
         cc.call(
             cc.internal("iterator_to_list"),
             [
                 cc.call(
                     cc.internal("generator_expression"),
                     [
                         cc.function_expression([cc.arg("x")], [cc.ret(cc.ref("y"))]),
                         cc.ref("xs")
                     ]
                 )
             ]
         )
     )
示例#2
0
 def test_generator_is_transformed_to_function_call_with_anonymous_function(self):
     _assert_transform(
         nodes.generator_expression(
             nodes.ref("y"),
             nodes.ref("x"),
             nodes.ref("xs")
         ),
         cc.call(
             cc.internal("generator_expression"),
             [
                 cc.function_expression([cc.arg("x")], [cc.ret(cc.ref("y"))]),
                 cc.ref("xs")
             ]
         )
     )