Author: Antonio Cuni <anto.c...@gmail.com> Branch: Changeset: r44774:f757d142e018 Date: 2011-06-07 11:15 +0200 http://bitbucket.org/pypy/pypy/changeset/f757d142e018/
Log: port this test to test_pypy_c_new 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 @@ -223,31 +223,6 @@ return total ''' % startvalue, 170, ([], startvalue + 4999450000L)) - def test_revert_shift(self): - from sys import maxint - tests = [] - for a in (1, 4, 8, 100): - for b in (-10, 10, -201, 201, -maxint/3, maxint/3): - for c in (-10, 10, -maxint/3, maxint/3): - tests.append(([a, b, c], long(4000*(a+b+c)))) - self.run_source(''' - def main(a, b, c): - from sys import maxint - i = sa = 0 - while i < 2000: - if 0 < a < 10: pass - if -100 < b < 100: pass - if -maxint/2 < c < maxint/2: pass - sa += (a<<a)>>a - sa += (b<<a)>>a - sa += (c<<a)>>a - sa += (a<<100)>>100 - sa += (b<<100)>>100 - sa += (c<<100)>>100 - i += 1 - return long(sa) - ''', 93, count_debug_merge_point=False, *tests) - def test_mod(self): avalues = ('a', 'b', 7, -42, 8) diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py --- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py +++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py @@ -1820,6 +1820,34 @@ for b in (0, 1, 2, 31, 32, 33, 61, 62, 63): self.run_and_check(main, [a, b], threshold=200) + def test_revert_shift_allcases(self): + """ + This test only checks that we get the expected result, not that any + optimization has been applied. + """ + from sys import maxint + + def main(a, b, c): + from sys import maxint + i = sa = 0 + while i < 300: + if 0 < a < 10: pass + if -100 < b < 100: pass + if -maxint/2 < c < maxint/2: pass + sa += (a<<a)>>a + sa += (b<<a)>>a + sa += (c<<a)>>a + sa += (a<<100)>>100 + sa += (b<<100)>>100 + sa += (c<<100)>>100 + i += 1 + return long(sa) + + for a in (1, 4, 8, 100): + for b in (-10, 10, -201, 201, -maxint/3, maxint/3): + for c in (-10, 10, -maxint/3, maxint/3): + self.run_and_check(main, [a, b, c], threshold=200) + def test_oldstyle_newstyle_mix(self): def main(): class A: _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit