[pypy-svn] pypy default: port test_intbound_simple to test_pypy_c_new
antocuni
commits-noreply at bitbucket.org
Thu Apr 14 14:43:56 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r43340:502a16c3a752
Date: 2011-04-14 13:44 +0200
http://bitbucket.org/pypy/pypy/changeset/502a16c3a752/
Log: port test_intbound_simple 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
@@ -920,8 +920,10 @@
self.run_and_check(src, threshold=400)
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
+ """
+ This test only checks that we get the expected result, not that any
+ optimization has been applied.
+ """
compares = ('a == b', 'b == a', 'a != b', 'b != a', 'a == c', 'c != b')
for e1 in compares:
for e2 in compares:
@@ -1071,3 +1073,39 @@
--TICK--
jump(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, i28, i25, i19, i13, p14, p15, descr=<Loop0>)
""")
+
+ def test_intbound_simple(self):
+ """
+ This test only checks that we get the expected result, not that any
+ optimization has been applied.
+ """
+ ops = ('<', '>', '<=', '>=', '==', '!=')
+ nbr = (3, 7)
+ for o1 in ops:
+ for o2 in ops:
+ for n1 in nbr:
+ for n2 in nbr:
+ src = '''
+ def f(i):
+ a, b = 3, 3
+ if i %s %d:
+ a = 0
+ else:
+ a = 1
+ if i %s %d:
+ 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
+
+ ''' % (o1, n1, o2, n2)
+ 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
@@ -224,43 +224,6 @@
''' % startvalue, 170, ([], startvalue + 4999450000L))
- def test_intbound_simple(self):
- ops = ('<', '>', '<=', '>=', '==', '!=')
- nbr = (3, 7)
- for o1 in ops:
- for o2 in ops:
- for n1 in nbr:
- for n2 in nbr:
- src = '''
- def f(i):
- a, b = 3, 3
- if i %s %d:
- a = 0
- else:
- a = 1
- if i %s %d:
- 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
-
- ''' % (o1, n1, o2, n2)
-
- exec(str(py.code.Source(src)))
- res = [0] * 4
- for i in range(15):
- res[f(i)] += 1500
- self.run_source(src, 268, ([], res))
-
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',
More information about the Pypy-commit
mailing list