Author: Armin Rigo <[email protected]>
Branch: py3.6
Changeset: r91879:984030944ee1
Date: 2017-07-15 14:38 +0200
http://bitbucket.org/pypy/pypy/changeset/984030944ee1/

Log:    (johanfforsberg, arigo)

        Passing test: "yield" statements inside "async" functions compile to
        AST already

diff --git a/pypy/interpreter/astcompiler/test/test_astbuilder.py 
b/pypy/interpreter/astcompiler/test/test_astbuilder.py
--- a/pypy/interpreter/astcompiler/test/test_astbuilder.py
+++ b/pypy/interpreter/astcompiler/test/test_astbuilder.py
@@ -1399,6 +1399,20 @@
         assert isinstance(asyncwith.body[0], ast.Expr)
         assert isinstance(asyncwith.body[0].value, ast.Num)
 
+    def test_asyncYield(self):
+        mod = self.get_ast("async def f():\n yield 5")
+        assert isinstance(mod, ast.Module)
+        assert len(mod.body) == 1
+        asyncdef = mod.body[0]
+        assert isinstance(asyncdef, ast.AsyncFunctionDef)
+        assert asyncdef.name == 'f'
+        assert asyncdef.args.args == None
+        assert len(asyncdef.body) == 1
+        expr = asyncdef.body[0]
+        assert isinstance(expr, ast.Expr)
+        assert isinstance(expr.value, ast.Yield)
+        assert isinstance(expr.value.value, ast.Num)
+
     def test_decode_error_in_string_literal(self):
         input = "u'\\x'"
         exc = py.test.raises(SyntaxError, self.get_ast, input).value
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to