Author: Antonio Cuni <[email protected]>
Branch: continulet-no-frame-loop-2
Changeset: r93057:37701890010b
Date: 2017-11-16 16:25 +0100
http://bitbucket.org/pypy/pypy/changeset/37701890010b/

Log:    cherry pick two failing tests from the branch continulet-no-frame-
        loop

diff --git a/pypy/module/_continuation/test/test_stacklet.py 
b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -365,27 +365,47 @@
         assert res == 2002
         assert seen == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
 
-    def test_f_back(self):
+    def test_f_back_no_cycles(self):
         import sys
         from _continuation import continulet
         stack = self.stack
         #
         def bar(c):
-            assert stack() == ['bar', 'foo', 'test_f_back']
+            f = sys._getframe(0)
+            assert stack() == ['bar', 'foo', 'test_f_back_no_cycles']
+            c.switch(f)
+            assert stack() == ['bar', 'foo', 'test_f_back_no_cycles']
+        def foo(c):
+            bar(c)
+        #
+        c = continulet(foo)
+        assert stack() == ['test_f_back_no_cycles']
+        f = c.switch()
+        assert stack() == ['test_f_back_no_cycles']
+        assert stack(f) == ['bar', 'foo']
+        c.switch()
+
+    def test_f_back_complex(self):
+        import sys
+        from _continuation import continulet
+        stack = self.stack
+        #
+        def bar(c):
+            assert stack() == ['bar', 'foo', 'test_f_back_complex']
             c.switch(sys._getframe(0))
             c.switch(sys._getframe(0).f_back)
             c.switch(sys._getframe(1))
             #
-            assert stack() == ['bar', 'foo', 'main', 'test_f_back']
+            assert stack() == ['bar', 'foo', 'main', 'test_f_back_complex']
             c.switch(sys._getframe(1).f_back)
             #
-            assert stack() == ['bar', 'foo', 'main2', 'test_f_back']
+            assert stack() == ['bar', 'foo', 'main2', 'test_f_back_complex']
             assert sys._getframe(2) is f3_foo.f_back
             c.switch(sys._getframe(2))
         def foo(c):
             bar(c)
         #
-        assert stack() == ['test_f_back']
+        assert stack() == ['test_f_back_complex']
         c = continulet(foo)
         f1_bar = c.switch()
         assert f1_bar.f_code.co_name == 'bar'
@@ -398,15 +418,16 @@
         def main():
             f4_main = c.switch()
             assert f4_main.f_code.co_name == 'main'
-            assert f3_foo.f_back is f1_bar    # not running, so a loop
-            assert stack() == ['main', 'test_f_back']
-            assert stack(f1_bar) == ['bar', 'foo', '...']
+            assert f3_foo.f_back is None    # not running
+            assert stack() == ['main', 'test_f_back_complex']
+            assert stack(f1_bar) == ['bar', 'foo']
         #
         def main2():
             f5_main2 = c.switch()
             assert f5_main2.f_code.co_name == 'main2'
-            assert f3_foo.f_back is f1_bar    # not running, so a loop
-            assert stack(f1_bar) == ['bar', 'foo', '...']
+            assert f3_foo.f_back is None    # not running
+            assert stack() == ['main2', 'test_f_back_complex']
+            assert stack(f1_bar) == ['bar', 'foo']
         #
         main()
         main2()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to