[pypy-commit] pypy default: add a test_zjit for pow

bdkearns noreply at buildbot.pypy.org
Thu Apr 17 07:40:14 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r70683:f2bdd3baf2d1
Date: 2014-04-17 01:26 -0400
http://bitbucket.org/pypy/pypy/changeset/f2bdd3baf2d1/

Log:	add a test_zjit for pow

diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -388,6 +388,8 @@
             w_res = w_lhs.descr_mul(interp.space, w_rhs)
         elif self.name == '-':
             w_res = w_lhs.descr_sub(interp.space, w_rhs)
+        elif self.name == '**':
+            w_res = w_lhs.descr_pow(interp.space, w_rhs)
         elif self.name == '->':
             if isinstance(w_rhs, FloatObject):
                 w_rhs = IntObject(int(w_rhs.floatval))
@@ -622,7 +624,7 @@
     (':', 'colon'),
     ('\w+', 'identifier'),
     ('\]', 'array_right'),
-    ('(->)|[\+\-\*\/]', 'operator'),
+    ('(->)|[\+\-\*\/]+', 'operator'),
     ('=', 'assign'),
     (',', 'comma'),
     ('\|', 'pipe'),
diff --git a/pypy/module/micronumpy/test/test_zjit.py b/pypy/module/micronumpy/test/test_zjit.py
--- a/pypy/module/micronumpy/test/test_zjit.py
+++ b/pypy/module/micronumpy/test/test_zjit.py
@@ -115,6 +115,38 @@
             'setfield_gc': 6,
         })
 
+    def define_pow():
+        return """
+        a = |30| ** 2
+        a -> 3
+        """
+
+    def test_pow(self):
+        result = self.run("pow")
+        assert result == 3 ** 2
+        self.check_trace_count(1)
+        self.check_simple_loop({
+            'call': 3,
+            'float_add': 1,
+            'float_eq': 3,
+            'float_mul': 2,
+            'float_ne': 1,
+            'getarrayitem_gc': 3,
+            'getfield_gc': 7,
+            'guard_false': 4,
+            'guard_not_invalidated': 1,
+            'guard_true': 5,
+            'int_add': 9,
+            'int_ge': 1,
+            'int_is_true': 1,
+            'int_lt': 3,
+            'jump': 1,
+            'raw_load': 2,
+            'raw_store': 1,
+            'setarrayitem_gc': 3,
+            'setfield_gc': 6,
+        })
+
     def define_sum():
         return """
         a = |30|


More information about the pypy-commit mailing list