[pypy-svn] pypy default: port test_intbound_addsub_mix to test_pypy_c_new
antocuni
commits-noreply at bitbucket.org
Thu Apr 14 14:43:57 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r43341:b84f08236871
Date: 2011-04-14 13:46 +0200
http://bitbucket.org/pypy/pypy/changeset/b84f08236871/
Log: port test_intbound_addsub_mix to test_pypy_c_new
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
@@ -1109,3 +1109,38 @@
''' % (o1, n1, o2, n2)
self.run_and_check(src, threshold=400)
+
+ def test_intbound_addsub_mix(self):
+ """
+ This test only checks that we get the expected result, not that any
+ optimization has been applied.
+ """
+ tests = ('i > 4', 'i > 2', 'i + 1 > 2', '1 + i > 4',
+ 'i - 1 > 1', '1 - i > 1', '1 - i < -3',
+ 'i == 1', 'i == 5', 'i != 1', '-2 * i < -4')
+ for t1 in tests:
+ for t2 in tests:
+ src = '''
+ def f(i):
+ a, b = 3, 3
+ if %s:
+ a = 0
+ else:
+ a = 1
+ if %s:
+ b = 0
+ else:
+ b = 1
+ return a + b * 2
+
+ def main():
+ res = [0] * 4
+ idx = []
+ for i in range(15):
+ idx.extend([i] * 500)
+ for i in idx:
+ res[f(i)] += 1
+ return res
+
+ ''' % (t1, t2)
+ self.run_and_check(src, threshold=400)
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,44 +223,6 @@
return total
''' % startvalue, 170, ([], startvalue + 4999450000L))
-
- def test_intbound_addsub_mix(self):
- tests = ('i > 4', 'i > 2', 'i + 1 > 2', '1 + i > 4',
- 'i - 1 > 1', '1 - i > 1', '1 - i < -3',
- 'i == 1', 'i == 5', 'i != 1', '-2 * i < -4')
- for t1 in tests:
- for t2 in tests:
- print t1, t2
- src = '''
- def f(i):
- a, b = 3, 3
- if %s:
- a = 0
- else:
- a = 1
- if %s:
- b = 0
- else:
- b = 1
- return a + b * 2
-
- def main():
- res = [0] * 4
- idx = []
- for i in range(15):
- idx.extend([i] * 1500)
- for i in idx:
- res[f(i)] += 1
- return res
-
- ''' % (t1, t2)
-
- exec(str(py.code.Source(src)))
- res = [0] * 4
- for i in range(15):
- res[f(i)] += 1500
- self.run_source(src, 280, ([], res))
-
def test_intbound_gt(self):
self.run_source('''
def main():
More information about the Pypy-commit
mailing list