[pypy-commit] pypy default: Test and fix.
arigo
noreply at buildbot.pypy.org
Thu Mar 15 01:44:10 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r53630:1212ff3d9858
Date: 2012-03-14 17:43 -0700
http://bitbucket.org/pypy/pypy/changeset/1212ff3d9858/
Log: Test and fix.
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -137,8 +137,11 @@
maxint = int(LONG_TEST - 1)
def is_valid_int(r):
- return isinstance(r, (int, long)) and (
+ if objectmodel.we_are_translated():
+ return isinstance(r, int)
+ return type(r) in (int, long) and (
-maxint - 1 <= r <= maxint)
+is_valid_int._annspecialcase_ = 'specialize:argtype(0)'
def ovfcheck(r):
"NOT_RPYTHON"
diff --git a/pypy/rlib/test/test_rarithmetic.py b/pypy/rlib/test/test_rarithmetic.py
--- a/pypy/rlib/test/test_rarithmetic.py
+++ b/pypy/rlib/test/test_rarithmetic.py
@@ -330,6 +330,12 @@
return a == b
py.test.raises(MissingRTypeOperation, "self.interpret(f, [42.0])")
+ def test_is_valid_int(self):
+ def f(x):
+ return is_valid_int(x) * 2 + is_valid_int(x + 0.5)
+ res = self.interpret(f, [123])
+ assert res == 2
+
class TestLLtype(BaseTestRarithmetic, LLRtypeMixin):
pass
More information about the pypy-commit
mailing list