Author: David Schneider <[email protected]>
Branch: arm-backend-2
Changeset: r48747:7cb3b3ddfee2
Date: 2011-11-04 12:11 +0100
http://bitbucket.org/pypy/pypy/changeset/7cb3b3ddfee2/

Log:    add some more tests for intergers and guards to cover unary and
        unsigned cmp ops

diff --git a/pypy/jit/backend/test/runner_test.py 
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -1205,6 +1205,37 @@
             got = longlong.getrealfloat(self.cpu.get_latest_value_float(i))
             assert got == 13.5 + 6.73 * i
 
+    def test_integers_and_guards2(self):
+        for opname, compare in [
+            (rop.INT_IS_TRUE, lambda x: bool(x)),
+            (rop.INT_IS_ZERO, lambda x: not bool(x))]:
+            for opguard, guard_case in [
+                (rop.GUARD_FALSE, False),
+                (rop.GUARD_TRUE,  True),
+                ]:
+                box = BoxInt()
+                res = BoxInt()
+                faildescr1 = BasicFailDescr(1)
+                faildescr2 = BasicFailDescr(2)
+                inputargs = [box]
+                operations = [
+                    ResOperation(opname, [box], res),
+                    ResOperation(opguard, [res], None, descr=faildescr1),
+                    ResOperation(rop.FINISH, [], None, descr=faildescr2),
+                    ]
+                operations[1].setfailargs([])
+                looptoken = LoopToken()
+                self.cpu.compile_loop(inputargs, operations, looptoken)
+                #
+                cpu = self.cpu
+                for value in [-42, 0, 1, 10]:
+                    cpu.set_future_value_int(0, value)
+                    fail = cpu.execute_token(looptoken)
+                    #
+                    expected = compare(value)
+                    expected ^= guard_case
+                    assert fail.identifier == 2 - expected
+
     def test_integers_and_guards(self):
         for opname, compare in [
             (rop.INT_LT, lambda x, y: x < y),
@@ -1243,9 +1274,9 @@
                     self.cpu.compile_loop(inputargs, operations, looptoken)
                     #
                     cpu = self.cpu
-                    for test1 in [-65, -42, -11]:
+                    for test1 in [-65, -42, -11, 0, 1, 10]:
                         if test1 == -42 or combinaison[0] == 'b':
-                            for test2 in [-65, -42, -11]:
+                            for test2 in [-65, -42, -11, 0, 1, 10]:
                                 if test2 == -42 or combinaison[1] == 'b':
                                     n = 0
                                     if combinaison[0] == 'b':
@@ -1260,6 +1291,59 @@
                                     expected ^= guard_case
                                     assert fail.identifier == 2 - expected
 
+    def test_integers_and_guards_uint(self):
+        for opname, compare in [
+            (rop.UINT_LE, lambda x, y: (x) <= (y)),
+            (rop.UINT_GT, lambda x, y: (x) >  (y)),
+            (rop.UINT_LT, lambda x, y: (x) <  (y)),
+            (rop.UINT_GE, lambda x, y: (x) >= (y)),
+            ]:
+            for opguard, guard_case in [
+                (rop.GUARD_FALSE, False),
+                (rop.GUARD_TRUE,  True),
+                ]:
+                for combinaison in ["bb", "bc", "cb"]:
+                    #
+                    if combinaison[0] == 'b':
+                        ibox1 = BoxInt()
+                    else:
+                        ibox1 = ConstInt(42)
+                    if combinaison[1] == 'b':
+                        ibox2 = BoxInt()
+                    else:
+                        ibox2 = ConstInt(42)
+                    b1 = BoxInt()
+                    faildescr1 = BasicFailDescr(1)
+                    faildescr2 = BasicFailDescr(2)
+                    inputargs = [ib for ib in [ibox1, ibox2]
+                                    if isinstance(ib, BoxInt)]
+                    operations = [
+                        ResOperation(opname, [ibox1, ibox2], b1),
+                        ResOperation(opguard, [b1], None, descr=faildescr1),
+                        ResOperation(rop.FINISH, [], None, descr=faildescr2),
+                        ]
+                    operations[-2].setfailargs([])
+                    looptoken = LoopToken()
+                    self.cpu.compile_loop(inputargs, operations, looptoken)
+                    #
+                    cpu = self.cpu
+                    for test1 in [65, 42, 11, 0, 1]:
+                        if test1 == 42 or combinaison[0] == 'b':
+                            for test2 in [65, 42, 11, 0, 1]:
+                                if test2 == 42 or combinaison[1] == 'b':
+                                    n = 0
+                                    if combinaison[0] == 'b':
+                                        cpu.set_future_value_int(n, test1)
+                                        n += 1
+                                    if combinaison[1] == 'b':
+                                        cpu.set_future_value_int(n, test2)
+                                        n += 1
+                                    fail = cpu.execute_token(looptoken)
+                                    #
+                                    expected = compare(test1, test2)
+                                    expected ^= guard_case
+                                    assert fail.identifier == 2 - expected
+
     def test_floats_and_guards(self):
         if not self.cpu.supports_floats:
             py.test.skip("requires floats")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to