[pypy-svn] pypy default: port test_kwargs from test_pypy_c

antocuni commits-noreply at bitbucket.org
Tue Mar 15 18:23:26 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42663:f4c727a84552
Date: 2011-03-15 12:27 +0100
http://bitbucket.org/pypy/pypy/changeset/f4c727a84552/

Log:	port test_kwargs from test_pypy_c

diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -295,6 +295,28 @@
             i16 = force_token()
         """)
 
+    def test_kwargs(self):
+        # this is not a very precise test, could be improved
+        def main(x):
+            def g(**args):
+                return len(args)
+            #
+            s = 0
+            d = {}
+            for i in range(x):
+                s += g(**d)       # ID: call
+                d[str(i)] = i
+                if i % 100 == 99:
+                    d = {}
+            return s
+        #
+        log = self.run(main, [1000], threshold=400)
+        assert log.result == 49500
+        loop, = log.loops_by_id('call')
+        ops = log.opnames(loop.ops_by_id('call'))
+        guards = [ops for ops in ops if ops.startswith('guard')]
+        assert len(guards) <= 5
+
     def test_reraise(self):
         def f(n):
             i = 0


More information about the Pypy-commit mailing list