[pypy-svn] pypy default: port test_min_max to test_pypy_c_new
antocuni
commits-noreply at bitbucket.org
Fri Apr 15 10:35:22 CEST 2011
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r43377:7b8591c5ef70
Date: 2011-04-15 10:03 +0200
http://bitbucket.org/pypy/pypy/changeset/7b8591c5ef70/
Log: port test_min_max 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
@@ -1433,3 +1433,24 @@
f37 = getarrayitem_raw(i8, i36, descr=...)
...
""")
+
+ def test_min_max(self):
+ def main():
+ i=0
+ sa=0
+ while i < 300:
+ sa+=min(max(i, 3000), 4000)
+ i+=1
+ return sa
+ log = self.run(main, [], threshold=200)
+ assert log.result == 300*3000
+ loop, = log.loops_by_filename(self.filepath)
+ assert loop.match("""
+ i7 = int_lt(i4, 300)
+ guard_true(i7, descr=...)
+ i9 = int_add_ovf(i5, 3000)
+ guard_no_overflow(descr=...)
+ i11 = int_add(i4, 1)
+ --TICK--
+ jump(p0, p1, p2, p3, i11, i9, descr=<Loop0>)
+ """)
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,16 +223,6 @@
return total
''' % startvalue, 170, ([], startvalue + 4999450000L))
- def test_min_max(self):
- self.run_source('''
- def main():
- i=0
- sa=0
- while i < 2000:
- sa+=min(max(i, 3000), 4000)
- i+=1
- return sa
- ''', 51, ([], 2000*3000))
def test_silly_max(self):
self.run_source('''
More information about the Pypy-commit
mailing list