[pypy-svn] pypy default: merge

fijal commits-noreply at bitbucket.org
Wed Apr 13 09:26:28 CEST 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r43323:7f8040abfc71
Date: 2011-04-13 09:26 +0200
http://bitbucket.org/pypy/pypy/changeset/7f8040abfc71/

Log:	merge

diff --git a/pypy/module/pypyjit/test/test_pypy_c.py b/pypy/module/pypyjit/test/test_pypy_c.py
--- a/pypy/module/pypyjit/test/test_pypy_c.py
+++ b/pypy/module/pypyjit/test/test_pypy_c.py
@@ -198,44 +198,6 @@
         print
         print '@' * 79
 
-    def test_f1(self):
-        self.run_source('''
-            def main(n):
-                "Arbitrary test function."
-                i = 0
-                x = 1
-                while i<n:
-                    j = 0   #ZERO
-                    while j<=i:
-                        j = j + 1
-                        x = x + (i&j)
-                    i = i + 1
-                return x
-        ''', 220,
-                   ([2117], 1083876708))
-
-    def test_factorial(self):
-        self.run_source('''
-            def main(n):
-                r = 1
-                while n > 1:
-                    r *= n
-                    n -= 1
-                return r
-        ''', 28,
-                   ([5], 120),
-                    ([25], 15511210043330985984000000L))
-
-    def test_factorialrec(self):
-        self.run_source('''
-            def main(n):
-                if n > 1:
-                    return n * main(n-1)
-                else:
-                    return 1
-        ''', 0,
-                   ([5], 120),
-                    ([25], 15511210043330985984000000L))
 
     def test_richards(self):
         self.run_source('''
@@ -247,529 +209,6 @@
         ''' % (sys.path,), 7200,
                    ([], 42))
 
-    def test_simple_call(self):
-        self.run_source('''
-            OFFSET = 0
-            def f(i):
-                return i + 1 + OFFSET
-            def main(n):
-                i = 0
-                while i < n+OFFSET:
-                    i = f(f(i))
-                return i
-        ''', 98,
-                   ([20], 20),
-                    ([31], 32))
-        ops = self.get_by_bytecode("LOAD_GLOBAL", True)
-        assert len(ops) == 5
-        assert ops[0].get_opnames() == ["guard_value",
-                                        "getfield_gc", "guard_value",
-                                        "getfield_gc", "guard_isnull",
-                                        "getfield_gc", "guard_nonnull_class"]
-        # the second getfield on the same globals is quicker
-        assert ops[1].get_opnames() == ["getfield_gc", "guard_nonnull_class"]
-        assert not ops[2] # second LOAD_GLOBAL of the same name folded away
-        # LOAD_GLOBAL of the same name but in different function partially
-        # folded away
-        # XXX could be improved
-        assert ops[3].get_opnames() == ["guard_value",
-                                        "getfield_gc", "guard_isnull"]
-        assert not ops[4]
-        ops = self.get_by_bytecode("CALL_FUNCTION", True)
-        assert len(ops) == 2
-        for i, bytecode in enumerate(ops):
-            if i == 0:
-                assert "call(getexecutioncontext)" in str(bytecode)
-            else:
-                assert not bytecode.get_opnames("call")
-            assert not bytecode.get_opnames("new")
-            assert len(bytecode.get_opnames("guard")) <= 10
-
-        ops = self.get_by_bytecode("LOAD_GLOBAL")
-        assert len(ops) == 5
-        for bytecode in ops:
-            assert not bytecode
-
-        ops = self.get_by_bytecode("CALL_FUNCTION")
-        assert len(ops) == 2
-        for bytecode in ops:
-            assert len(bytecode) <= 1
-        
-
-    def test_method_call(self):
-        self.run_source('''
-            class A(object):
-                def __init__(self, a):
-                    self.a = a
-                def f(self, i):
-                    return self.a + i
-            def main(n):
-                i = 0
-                a = A(1)
-                while i < n:
-                    x = a.f(i)
-                    i = a.f(x)
-                return i
-        ''', 93,
-                   ([20], 20),
-                    ([31], 32))
-        ops = self.get_by_bytecode("LOOKUP_METHOD", True)
-        assert len(ops) == 2
-        assert not ops[0].get_opnames("call")
-        assert not ops[0].get_opnames("new")
-        assert len(ops[0].get_opnames("guard")) <= 3
-        assert not ops[1] # second LOOKUP_METHOD folded away
-
-        ops = self.get_by_bytecode("LOOKUP_METHOD")
-        assert not ops[0] # first LOOKUP_METHOD folded away
-        assert not ops[1] # second LOOKUP_METHOD folded away
-
-        ops = self.get_by_bytecode("CALL_METHOD", True)
-        assert len(ops) == 2
-        for i, bytecode in enumerate(ops):
-            if i == 0:
-                assert "call(getexecutioncontext)" in str(bytecode)
-            else:
-                assert not bytecode.get_opnames("call")
-            assert not bytecode.get_opnames("new")
-            assert len(bytecode.get_opnames("guard")) <= 6
-        assert len(ops[1]) < len(ops[0])
-
-        ops = self.get_by_bytecode("CALL_METHOD")
-        assert len(ops) == 2
-        assert len(ops[0]) <= 1
-        assert len(ops[1]) <= 1
-        
-        ops = self.get_by_bytecode("LOAD_ATTR", True)
-        assert len(ops) == 2
-        # With mapdict, we get fast access to (so far) the 5 first
-        # attributes, which means it is done with only the following
-        # operations.  (For the other attributes there is additionally
-        # a getarrayitem_gc.)
-        assert ops[0].get_opnames() == ["getfield_gc",
-                                        "guard_nonnull_class"]
-        assert not ops[1] # second LOAD_ATTR folded away
-
-        ops = self.get_by_bytecode("LOAD_ATTR")
-        assert not ops[0] # first LOAD_ATTR folded away
-        assert not ops[1] # second LOAD_ATTR folded away
-
-    def test_static_classmethod_call(self):
-        self.run_source('''
-            class A(object):
-                @classmethod
-                def f(cls, i):
-                    return i + (cls is A) + 1
-
-                @staticmethod
-                def g(i):
-                    return i - 1
-
-            def main(n):
-                i = 0
-                a = A()
-                while i < n:
-                    x = a.f(i)
-                    i = a.g(x)
-                return i
-        ''', 106,
-                   ([20], 20),
-                   ([31], 31))
-        ops = self.get_by_bytecode("LOOKUP_METHOD")
-        assert len(ops) == 2
-        assert not ops[0].get_opnames("call")
-        assert not ops[0].get_opnames("new")
-        assert len(ops[0].get_opnames("guard")) <= 2
-        assert len(ops[0].get_opnames("getfield")) <= 4
-        assert not ops[1] # second LOOKUP_METHOD folded away
-
-    def test_default_and_kw(self):
-        self.run_source('''
-            def f(i, j=1):
-                return i + j
-            def main(n):
-                i = 0
-                while i < n:
-                    i = f(f(i), j=1)
-                return i
-        ''', 100,
-                   ([20], 20),
-                   ([31], 32))
-        ops = self.get_by_bytecode("CALL_FUNCTION")
-        assert len(ops) == 2
-        for i, bytecode in enumerate(ops):
-            assert not bytecode.get_opnames("call")
-            assert not bytecode.get_opnames("new")
-        assert len(ops[0].get_opnames("guard")) <= 14
-        assert len(ops[1].get_opnames("guard")) <= 3
-
-        ops = self.get_by_bytecode("CALL_FUNCTION", True)
-        assert len(ops) == 2
-        for i, bytecode in enumerate(ops):
-            if i == 0:
-                assert "call(getexecutioncontext)" in str(bytecode)
-            else:
-                assert not bytecode.get_opnames("call")
-            assert not bytecode.get_opnames("new")
-        assert len(ops[0].get_opnames("guard")) <= 14
-        assert len(ops[1].get_opnames("guard")) <= 3
-
-    def test_kwargs(self):
-        self.run_source('''
-            d = {}
-
-            def g(**args):
-                return len(args)
-
-            def main(x):
-                s = 0
-                d = {}
-                for i in range(x):
-                    s += g(**d)
-                    d[str(i)] = i
-                    if i % 100 == 99:
-                        d = {}
-                return s
-        ''', 100000, ([100], 4950),
-                    ([1000], 49500),
-                    ([10000], 495000),
-                    ([100000], 4950000))
-        assert len(self.rawloops)  + len(self.rawentrybridges) == 4
-        op, = self.get_by_bytecode("CALL_FUNCTION_KW")
-        # XXX a bit too many guards, but better than before
-        assert len(op.get_opnames("guard")) <= 12
-
-    def test_stararg_virtual(self):
-        self.run_source('''
-            d = {}
-
-            def g(*args):
-                return len(args)
-            def h(a, b, c):
-                return c
-
-            def main(x):
-                s = 0
-                for i in range(x):
-                    l = [i, x, 2]
-                    s += g(*l)
-                    s += h(*l)
-                    s += g(i, x, 2)
-                for i in range(x):
-                    l = [x, 2]
-                    s += g(i, *l)
-                    s += h(i, *l)
-                return s
-        ''', 100000, ([100], 1300),
-                    ([1000], 13000),
-                    ([10000], 130000),
-                    ([100000], 1300000))
-        assert len(self.loops) == 2
-        ops = self.get_by_bytecode("CALL_FUNCTION_VAR")
-        assert len(ops) == 4
-        for op in ops:
-            assert len(op.get_opnames("new")) == 0
-            assert len(op.get_opnames("call_may_force")) == 0
-
-        ops = self.get_by_bytecode("CALL_FUNCTION")
-        for op in ops:
-            assert len(op.get_opnames("new")) == 0
-            assert len(op.get_opnames("call_may_force")) == 0
-
-    def test_stararg(self):
-        self.run_source('''
-            d = {}
-
-            def g(*args):
-                return args[-1]
-            def h(*args):
-                return len(args)
-
-            def main(x):
-                s = 0
-                l = []
-                i = 0
-                while i < x:
-                    l.append(1)
-                    s += g(*l)
-                    i = h(*l)
-                return s
-        ''', 100000, ([100], 100),
-                     ([1000], 1000),
-                     ([2000], 2000),
-                     ([4000], 4000))
-        assert len(self.loops) == 1
-        ops = self.get_by_bytecode("CALL_FUNCTION_VAR")
-        for op in ops:
-            assert len(op.get_opnames("new_with_vtable")) == 0
-            assert len(op.get_opnames("call_may_force")) == 0
-
-    def test_virtual_instance(self):
-        self.run_source('''
-            class A(object):
-                pass
-            def main(n):
-                i = 0
-                while i < n:
-                    a = A()
-                    assert isinstance(a, A)
-                    assert not isinstance(a, int)
-                    a.x = 2
-                    i = i + a.x
-                return i
-        ''', 69,
-                   ([20], 20),
-                   ([31], 32))
-
-        callA, callisinstance1, callisinstance2 = (
-                self.get_by_bytecode("CALL_FUNCTION"))
-        assert not callA.get_opnames("call")
-        assert not callA.get_opnames("new")
-        assert len(callA.get_opnames("guard")) <= 2
-        assert not callisinstance1.get_opnames("call")
-        assert not callisinstance1.get_opnames("new")
-        assert len(callisinstance1.get_opnames("guard")) <= 2
-        # calling isinstance on a builtin type gives zero guards
-        # because the version_tag of a builtin type is immutable
-        assert not len(callisinstance1.get_opnames("guard"))
-
-
-        bytecode, = self.get_by_bytecode("STORE_ATTR")
-        assert bytecode.get_opnames() == []
-
-    def test_load_attr(self):
-        self.run_source('''
-            class A(object):
-                pass
-            a = A()
-            a.x = 2
-            def main(n):
-                i = 0
-                while i < n:
-                    i = i + a.x
-                return i
-        ''', 41,
-                   ([20], 20),
-                   ([31], 32))
-
-        load, = self.get_by_bytecode("LOAD_ATTR")
-        # 1 guard_value for the class
-        # 1 guard_value for the version_tag
-        # 1 guard_value for the structure
-        # 1 guard_nonnull_class for the result since it is used later
-        assert len(load.get_opnames("guard")) <= 4
-
-    def test_mixed_type_loop(self):
-        self.run_source('''
-            class A(object):
-                pass
-            def main(n):
-                i = 0.0
-                j = 2
-                while i < n:
-                    i = j + i
-                return i, type(i) is float
-        ''', 35,
-                   ([20], (20, True)),
-                   ([31], (32, True)))
-
-        bytecode, = self.get_by_bytecode("BINARY_ADD")
-        assert not bytecode.get_opnames("call")
-        assert not bytecode.get_opnames("new")
-        assert len(bytecode.get_opnames("guard")) <= 2
-
-    def test_call_builtin_function(self):
-        self.run_source('''
-            class A(object):
-                pass
-            def main(n):
-                i = 2
-                l = []
-                while i < n:
-                    i += 1
-                    l.append(i)
-                return i, len(l)
-        ''', 39,
-                   ([20], (20, 18)),
-                   ([31], (31, 29)))
-
-        bytecode, = self.get_by_bytecode("CALL_METHOD")
-        assert len(bytecode.get_opnames("new_with_vtable")) == 1 # the forcing of the int
-        assert len(bytecode.get_opnames("call")) == 1 # the call to append
-        assert len(bytecode.get_opnames("guard")) == 1 # guard for guard_no_exception after the call
-        bytecode, = self.get_by_bytecode("CALL_METHOD", True)
-        assert len(bytecode.get_opnames("guard")) == 2 # guard for profiling disabledness + guard_no_exception after the call
-
-    def test_range_iter(self):
-        self.run_source('''
-            def g(n):
-                return range(n)
-
-            def main(n):
-                s = 0
-                for i in range(n):
-                    s += g(n)[i]
-                return s
-        ''', 143, ([1000], 1000 * 999 / 2))
-        bytecode, = self.get_by_bytecode("BINARY_SUBSCR", True)
-        assert bytecode.get_opnames("guard") == [
-            "guard_false",   # check that the index is >= 0
-            "guard_false",   # check that the index is lower than the current length
-            ]
-        bytecode, _ = self.get_by_bytecode("FOR_ITER", True) # second bytecode is the end of the loop
-        assert bytecode.get_opnames("guard") == [
-            "guard_value",
-            "guard_class",   # check the class of the iterator
-            "guard_nonnull", # check that the iterator is not finished
-            "guard_isnull",  # check that the range list is not forced
-            "guard_false",   # check that the index is lower than the current length
-            ]
-
-        bytecode, = self.get_by_bytecode("BINARY_SUBSCR")
-        assert bytecode.get_opnames("guard") == [
-            "guard_false",   # check that the index is >= 0
-            "guard_false",   # check that the index is lower than the current length
-            ]
-        bytecode, _ = self.get_by_bytecode("FOR_ITER") # second bytecode is the end of the loop
-        assert bytecode.get_opnames("guard") == [
-            "guard_false",   # check that the index is lower than the current length
-            ]
-
-    def test_exception_inside_loop_1(self):
-        self.run_source('''
-            def main(n):
-                while n:
-                    try:
-                        raise ValueError
-                    except ValueError:
-                        pass
-                    n -= 1
-                return n
-        ''', 33,
-                  ([30], 0))
-
-        bytecode, = self.get_by_bytecode("SETUP_EXCEPT")
-        #assert not bytecode.get_opnames("new")   -- currently, we have
-        #               new_with_vtable(pypy.interpreter.pyopcode.ExceptBlock)
-        bytecode, = self.get_by_bytecode("RAISE_VARARGS")
-        assert not bytecode.get_opnames("new")
-        bytecode, = self.get_by_bytecode("COMPARE_OP")
-        assert not bytecode.get_opnames()
-
-    def test_exception_inside_loop_2(self):
-        self.run_source('''
-            def g(n):
-                raise ValueError(n)
-            def f(n):
-                g(n)
-            def main(n):
-                while n:
-                    try:
-                        f(n)
-                    except ValueError:
-                        pass
-                    n -= 1
-                return n
-        ''', 51,
-                  ([30], 0))
-
-        bytecode, = self.get_by_bytecode("RAISE_VARARGS")
-        assert not bytecode.get_opnames("new")
-        bytecode, = self.get_by_bytecode("COMPARE_OP")
-        assert len(bytecode.get_opnames()) <= 2    # oois, guard_true
-
-    def test_chain_of_guards(self):
-        self.run_source('''
-        class A(object):
-            def method_x(self):
-                return 3
-
-        l = ["x", "y"]
-
-        def main(arg):
-            sum = 0
-            a = A()
-            i = 0
-            while i < 2000:
-                name = l[arg]
-                sum += getattr(a, 'method_' + name)()
-                i += 1
-            return sum
-        ''', 3000, ([0], 2000*3))
-        assert len(self.loops) == 1
-
-    def test_getattr_with_dynamic_attribute(self):
-        self.run_source('''
-        class A(object):
-            pass
-
-        l = ["x", "y"]
-
-        def main(arg):
-            sum = 0
-            a = A()
-            a.a1 = 0
-            a.a2 = 0
-            a.a3 = 0
-            a.a4 = 0
-            a.a5 = 0 # workaround, because the first five attributes need a promotion
-            a.x = 1
-            a.y = 2
-            i = 0
-            while i < 2000:
-                name = l[i % 2]
-                sum += getattr(a, name)
-                i += 1
-            return sum
-        ''', 3000, ([0], 3000))
-        assert len(self.loops) == 1
-
-    def test_blockstack_virtualizable(self):
-        self.run_source('''
-        from pypyjit import residual_call
-
-        def main():
-            i = 0
-            while i < 100:
-                try:
-                    residual_call(len, [])
-                except:
-                    pass
-                i += 1
-            return i
-        ''', 1000, ([], 100))
-        bytecode, = self.get_by_bytecode("CALL_FUNCTION")
-        # we allocate virtual ref and frame, we don't want block
-        assert len(bytecode.get_opnames('new_with_vtable')) == 2
-
-    def test_import_in_function(self):
-        self.run_source('''
-        def main():
-            i = 0
-            while i < 100:
-                from sys import version
-                i += 1
-            return i
-        ''', 100, ([], 100))
-        bytecode, = self.get_by_bytecode('IMPORT_NAME')
-        bytecode2, = self.get_by_bytecode('IMPORT_FROM')
-        assert len(bytecode.get_opnames('call')) == 2 # split_chr and list_pop
-        assert len(bytecode2.get_opnames('call')) == 0
-
-    def test_arraycopy_disappears(self):
-        self.run_source('''
-        def main():
-            i = 0
-            while i < 100:
-                t = (1, 2, 3, i + 1)
-                t2 = t[:]
-                del t
-                i = t2[3]
-                del t2
-            return i
-        ''', 40, ([], 100))
-        bytecode, = self.get_by_bytecode('BINARY_SUBSCR')
-        assert len(bytecode.get_opnames('new_array')) == 0
 
     def test_overflow_checking(self):
         startvalue = sys.maxint - 2147483647
@@ -783,269 +222,6 @@
                 total += f(i, 5)
             return total
         ''' % startvalue, 170, ([], startvalue + 4999450000L))
-
-    def test_boolrewrite_invers(self):
-        for a, b, res, ops in (('2000', '2000', 20001000, 51),
-                               ( '500',  '500', 15001500, 81),
-                               ( '300',  '600', 16001700, 83),
-                               (   'a',    'b', 16001700, 89),
-                               (   'a',    'a', 13001700, 85)):
-
-            self.run_source('''
-            def main():
-                sa = 0
-                a = 300
-                b = 600
-                for i in range(1000):
-                    if i < %s: sa += 1
-                    else: sa += 2
-                    if i >= %s: sa += 10000
-                    else: sa += 20000
-                return sa
-            '''%(a, b), ops, ([], res))
-
-    def test_boolrewrite_reflex(self):
-        for a, b, res, ops in (('2000', '2000', 10001000, 51),
-                               ( '500',  '500', 15001500, 81),
-                               ( '300',  '600', 14001700, 83),
-                               (   'a',    'b', 14001700, 89),
-                               (   'a',    'a', 17001700, 85)):
-
-            self.run_source('''
-            def main():
-                sa = 0
-                a = 300
-                b = 600
-                for i in range(1000):
-                    if i < %s: sa += 1
-                    else: sa += 2
-                    if %s > i: sa += 10000
-                    else: sa += 20000
-                return sa
-            '''%(a, b), ops, ([], res))
-
-
-    def test_boolrewrite_correct_invers(self):
-        def opval(i, op, a):
-            if eval('%d %s %d' % (i, op, a)): return 1
-            return 2
-
-        ops = ('<', '>', '<=', '>=', '==', '!=')        
-        for op1 in ops:
-            for op2 in ops:
-                for a,b in ((500, 500), (300, 600)):
-                    res = 0
-                    res += opval(a-1, op1, a) * (a)
-                    res += opval(  a, op1, a) 
-                    res += opval(a+1, op1, a) * (1000 - a - 1)
-                    res += opval(b-1, op2, b) * 10000 * (b)
-                    res += opval(  b, op2, b) * 10000 
-                    res += opval(b+1, op2, b) * 10000 * (1000 - b - 1)
-
-                    self.run_source('''
-                    def main():
-                        sa = 0
-                        for i in range(1000):
-                            if i %s %d: sa += 1
-                            else: sa += 2
-                            if i %s %d: sa += 10000
-                            else: sa += 20000
-                        return sa
-                    '''%(op1, a, op2, b), 83, ([], res))
-
-                    self.run_source('''
-                    def main():
-                        sa = 0
-                        i = 0.0
-                        while i < 250.0:
-                            if i %s %f: sa += 1
-                            else: sa += 2
-                            if i %s %f: sa += 10000
-                            else: sa += 20000
-                            i += 0.25
-                        return sa
-                    '''%(op1, float(a)/4.0, op2, float(b)/4.0), 156, ([], res))
-                    
-
-    def test_boolrewrite_correct_reflex(self):
-        def opval(i, op, a):
-            if eval('%d %s %d' % (i, op, a)): return 1
-            return 2
-
-        ops = ('<', '>', '<=', '>=', '==', '!=')        
-        for op1 in ops:
-            for op2 in ops:
-                for a,b in ((500, 500), (300, 600)):
-                    res = 0
-                    res += opval(a-1, op1, a) * (a)
-                    res += opval(  a, op1, a) 
-                    res += opval(a+1, op1, a) * (1000 - a - 1)
-                    res += opval(b, op2, b-1) * 10000 * (b)
-                    res += opval(b, op2,   b) * 10000
-                    res += opval(b, op2, b+1) * 10000 * (1000 - b - 1)
-
-                    self.run_source('''
-                    def main():
-                        sa = 0
-                        for i in range(1000):
-                            if i %s %d: sa += 1
-                            else: sa += 2
-                            if %d %s i: sa += 10000
-                            else: sa += 20000
-                        return sa
-                    '''%(op1, a, b, op2), 83, ([], res))
-
-                    self.run_source('''
-                    def main():
-                        sa = 0
-                        i = 0.0
-                        while i < 250.0:
-                            if i %s %f: sa += 1
-                            else: sa += 2
-                            if %f %s i: sa += 10000
-                            else: sa += 20000
-                            i += 0.25
-                        return sa
-                    '''%(op1, float(a)/4.0, float(b)/4.0, op2), 156, ([], res))
-
-    def test_boolrewrite_ptr(self):
-        # XXX this test is way too imprecise in what it is actually testing
-        # it should count the number of guards instead
-        compares = ('a == b', 'b == a', 'a != b', 'b != a', 'a == c', 'c != b')
-        for e1 in compares:
-            for e2 in compares:
-                a, b, c = 1, 2, 3
-                if eval(e1): res = 752 * 1 
-                else: res = 752 * 2 
-                if eval(e2): res += 752 * 10000 
-                else: res += 752 * 20000 
-                a = b
-                if eval(e1): res += 248 * 1
-                else: res += 248 * 2
-                if eval(e2): res += 248 * 10000
-                else: res += 248 * 20000
-
-
-                if 'c' in e1 or 'c' in e2:
-                    n = 337
-                else:
-                    n = 215
-
-                print
-                print 'Test:', e1, e2, n, res
-                self.run_source('''
-                class tst(object):
-                    pass
-                def main():
-                    a = tst()
-                    b = tst()
-                    c = tst()
-                    sa = 0
-                    for i in range(1000):
-                        if %s: sa += 1
-                        else: sa += 2
-                        if %s: sa += 10000
-                        else: sa += 20000
-                        if i > 750: a = b
-                    return sa
-                '''%(e1, e2), n, ([], res))
-
-    def test_array_sum(self):
-        for tc, maxops in zip('bhilBHILfd', (38,) * 6 + (40, 40, 41, 38)):
-            res = 19352859
-            if tc == 'L':
-                res = long(res)
-            elif tc in 'fd':
-                res = float(res)
-            elif tc == 'I' and sys.maxint == 2147483647:
-                res = long(res)
-                # note: in CPython we always get longs here, even on 64-bits
-
-            self.run_source('''
-            from array import array
-
-            def main():
-                img = array("%s", range(127) * 5) * 484
-                l, i = 0, 0
-                while i < 640 * 480:
-                    l += img[i]
-                    i += 1
-                return l
-            ''' % tc, maxops, ([], res))
-
-    def test_array_sum_char(self):
-        self.run_source('''
-            from array import array
-
-            def main():
-                img = array("c", "Hello") * 130 * 480
-                l, i = 0, 0
-                while i < 640 * 480:
-                    l += ord(img[i])
-                    i += 1
-                return l
-            ''', 60, ([], 30720000))
-
-    def test_array_sum_unicode(self):
-        self.run_source('''
-            from array import array
-
-            def main():
-                img = array("u", u"Hello") * 130 * 480
-                l, i = 0, 0
-                while i < 640 * 480:
-                    if img[i] == u"l":
-                        l += 1
-                    i += 1
-                return l
-            ''', 65, ([], 122880))
-
-    def test_array_intimg(self):
-        # XXX this test is way too imprecise in what it is actually testing
-        # it should count the number of guards instead
-        for tc, maxops in zip('ilILd', (67, 67, 70, 70, 61)):
-            print
-            print '='*65
-            print '='*20, 'running test for tc=%r' % (tc,), '='*20
-            res = 73574560
-            if tc == 'L':
-                res = long(res)
-            elif tc in 'fd':
-                res = float(res)
-            elif tc == 'I' and sys.maxint == 2147483647:
-                res = long(res)
-                # note: in CPython we always get longs here, even on 64-bits
-
-            self.run_source('''
-            from array import array
-
-            def main(tc):
-                img = array(tc, range(3)) * (350 * 480)
-                intimg = array(tc, (0,)) * (640 * 480)
-                l, i = 0, 640
-                while i < 640 * 480:
-                    l = l + img[i]
-                    intimg[i] = (intimg[i-640] + l) 
-                    i += 1
-                return intimg[i - 1]
-            ''', maxops, ([tc], res))
-
-    def test_unpackiterable(self):
-        self.run_source('''
-        from array import array
-
-        def main():
-            i = 0
-            t = array('l', (1, 2))
-            while i < 2000:
-                a, b = t
-                i += 1
-            return 3
-
-        ''', 100, ([], 3))
-        bytecode, = self.get_by_bytecode("UNPACK_SEQUENCE")
-        # we allocate virtual ref and frame, we don't want block
-        assert len(bytecode.get_opnames('call_may_force')) == 0
         
 
     def test_intbound_simple(self):


More information about the Pypy-commit mailing list