[pypy-svn] r32586 - in pypy/dist/pypy/jit/timeshifter: . test

arigo at codespeak.net arigo at codespeak.net
Fri Sep 22 18:23:38 CEST 2006


Author: arigo
Date: Fri Sep 22 18:23:36 2006
New Revision: 32586

Modified:
   pypy/dist/pypy/jit/timeshifter/rcontainer.py
   pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
   pypy/dist/pypy/jit/timeshifter/test/test_tlc.py
   pypy/dist/pypy/jit/timeshifter/vlist.py
Log:
(arre, arigo)  The first TLC test passes!


Modified: pypy/dist/pypy/jit/timeshifter/rcontainer.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/rcontainer.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/rcontainer.py	Fri Sep 22 18:23:36 2006
@@ -153,6 +153,7 @@
         #self.fz_content_boxes initialized later
 
     def exactmatch(self, vstruct, outgoingvarboxes, memo):
+        assert isinstance(vstruct, VirtualStruct)
         contmemo = memo.containers
         if self in contmemo:
             ok = vstruct is contmemo[self]

Modified: pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_timeshift.py	Fri Sep 22 18:23:36 2006
@@ -915,6 +915,7 @@
     def test_green_with_side_effects(self):
         S = lltype.GcStruct('S', ('flag', lltype.Bool))
         s = lltype.malloc(S)
+        s.flag = False
         def ll_set_flag(s):
             s.flag = True
         def ll_function():
@@ -922,7 +923,7 @@
             ll_set_flag(s)
             return s.flag
         res = self.timeshift(ll_function, [], [])
-        assert res is True
+        assert res == True
         self.check_insns({'setfield': 2, 'getfield': 1})
 
     def test_recursive_call(self):
@@ -959,7 +960,7 @@
                 g = g2
             return g(v)
 
-        res = self.timeshift(f, [False, 40], [0])
+        res = self.timeshift(f, [0, 40], [0])
         assert res == 42
         self.check_insns({'int_add': 1})
 
@@ -977,11 +978,11 @@
                 g = g2
             return g(v)
 
-        res = self.timeshift(f, [False, 40], [0])
+        res = self.timeshift(f, [0, 40], [0])
         assert res == 42
         self.check_insns({'int_add': 1})
 
-        res = self.timeshift(f, [True, 40], [0])
+        res = self.timeshift(f, [1, 40], [0])
         assert res == -17
         self.check_insns({})
 
@@ -1003,19 +1004,19 @@
                 g = g2
             return g(v) + w
 
-        res = self.timeshift(f, [False, 40], [0])
+        res = self.timeshift(f, [0, 40], [0])
         assert res == 25
         self.check_insns({'int_add': 2, 'int_ge': 1})
 
-        res = self.timeshift(f, [True, 40], [0])
+        res = self.timeshift(f, [1, 40], [0])
         assert res == -34
         self.check_insns({'int_ge': 2, 'int_add': 1})
 
-        res = self.timeshift(f, [False, -1000], [0])
+        res = self.timeshift(f, [0, -1000], [0])
         assert res == f(False, -1000)
         self.check_insns({'int_add': 2, 'int_ge': 1})
 
-        res = self.timeshift(f, [True, -1000], [0])
+        res = self.timeshift(f, [1, -1000], [0])
         assert res == f(True, -1000)
         self.check_insns({'int_ge': 2, 'int_add': 1})
 
@@ -1037,6 +1038,6 @@
                 o = Concrete()
             return o.m()
 
-        res = self.timeshift(f, [False], [0], policy=P_NOVIRTUAL)
+        res = self.timeshift(f, [0], [0], policy=P_NOVIRTUAL)
         assert res == 42
         self.check_insns({})

Modified: pypy/dist/pypy/jit/timeshifter/test/test_tlc.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/test/test_tlc.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/test/test_tlc.py	Fri Sep 22 18:23:36 2006
@@ -9,20 +9,20 @@
 from pypy.jit.tl.test.test_tl import FACTORIAL_SOURCE
 
 
+tlc_interp_without_call = func_with_new_name(
+    tlc.interp_without_call, "tlc_interp_without_call")
+# to stick attributes on the new function object, not on tlc.interp_wi*
+def build_bytecode(s):
+    result = ''.join([chr(int(t)) for t in s.split(',')])
+    return LLSupport.to_rstr(result)
+tlc_interp_without_call.convert_arguments = [build_bytecode, int, int]
+
+
 class TestTLC(TimeshiftingTests):
 
-    def test_tlc(self):
-        py.test.skip("in-progress")
+    def test_factorial(self):
         code = tlc.compile(FACTORIAL_SOURCE)
         bytecode = ','.join([str(ord(c)) for c in code])
-        tlc_interp_without_call = func_with_new_name(
-            tlc.interp_without_call, "tlc_interp_without_call")
-        # to stick attributes on the new function object, not on tlc.interp_wi*
-        def build_bytecode(s):
-            result = ''.join([chr(int(t)) for t in s.split(',')])
-            return LLSupport.to_rstr(result)
-        tlc_interp_without_call.convert_arguments = [build_bytecode, int, int]
-
         if Benchmark.ENABLED:
             n = 2500
             expected = 0      # far too many powers of 2 to be anything else
@@ -30,5 +30,24 @@
             n = 5
             expected = 120
         res = self.timeshift(tlc_interp_without_call, [bytecode, 0, n],
-                             [0, 1], policy=P_OOPSPEC, backendoptimize=True)
+                             [0, 1], policy=P_OOPSPEC)#, backendoptimize=True)
         assert res == expected
+
+    def test_nth_item(self):
+        py.test.skip("in-progress")
+        # get the nth item of a chained list
+        code = tlc.compile("""
+            NIL
+            PUSH 40
+            CONS
+            PUSH 20
+            CONS
+            PUSH 10
+            CONS
+            PUSHARG
+            DIV
+        """)
+        bytecode = ','.join([str(ord(c)) for c in code])
+        res = self.timeshift(tlc_interp_without_call, [bytecode, 0, 1],
+                             [0, 1], policy=P_OOPSPEC)#, backendoptimize=True)
+        assert res == 20

Modified: pypy/dist/pypy/jit/timeshifter/vlist.py
==============================================================================
--- pypy/dist/pypy/jit/timeshifter/vlist.py	(original)
+++ pypy/dist/pypy/jit/timeshifter/vlist.py	Fri Sep 22 18:23:36 2006
@@ -43,6 +43,7 @@
         #self.fz_item_boxes initialized later
 
     def exactmatch(self, vlist, outgoingvarboxes, memo):
+        assert isinstance(vlist, VirtualList)
         contmemo = memo.containers
         if self in contmemo:
             ok = vlist is contmemo[self]



More information about the Pypy-commit mailing list