Commits

Hakan Ardo committed 29f4c61

some tests

Comments (0)

Files changed (2)

pypy/jit/metainterp/test/test_ajit.py

             return sa
         assert self.meta_interp(f, [20, 1, 2]) == f(20, 1, 2)
 
+    def test_inlined_short_preamble_guard_needed_in_loop1(self):
+        class A(object):
+            def __init__(self, a):
+                self.a = a
+        myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa',
+                                                     'a', 'b'])
+        def f(n, a, b):
+            sa = i = 0
+            while i < n:
+                myjitdriver.jit_merge_point(n=n, i=i, sa=sa, a=a, b=b)
+                if a.a < 10:
+                    sa += a.a
+                b.a = i
+                i += 1
+            return sa
+        def g(n):
+            return f(n, A(5), A(10))
+        assert self.meta_interp(g, [20]) == g(20)
+
+    def test_inlined_short_preamble_guard_needed_in_loop2(self):
+        myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa',
+                                                     'a', 'b'])
+        def f(n):
+            sa = i = 0
+            a = b = []
+            while i < n:
+                myjitdriver.jit_merge_point(n=n, i=i, sa=sa, a=a, b=b)
+                a = []
+                sa += i
+                i += 1
+            return sa
+        assert self.meta_interp(f, [20]) == f(20)
+
+
+
+    def test_varray_boxed(self):
+        myjitdriver = JitDriver(greens = [], reds = ['a'])
+        a = []
+        while True:
+            myjitdriver.jit_merge_point(a=a)
+            a = []
+
 class TestOOtype(BasicTests, OOJitMixin):
 
     def test_oohash(self):

pypy/jit/metainterp/test/test_optimizeopt.py

         """
         self.optimize_loop(ops, expected, preamble)
 
+    def test_varray_boxed(self):
+        ops = """
+        [p8]
+        p31 = new(descr=ssize)
+        setfield_gc(p31, 0, descr=adescr)
+        p33 = new_array(0, descr=arraydescr)
+        setfield_gc(p31, p33, descr=bdescr)
+        p35 = new_with_vtable(ConstClass(node_vtable))
+        setfield_gc(p35, p31, descr=valuedescr)
+        jump(p35)
+        """
+        expected = """
+        []
+        jump()
+        """
+        self.optimize_loop(ops, expected)
+        
     def test_varray_1(self):
         ops = """
         [i1]