[pypy-svn] r15390 - in pypy/dist/pypy/rpython: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sat Jul 30 01:08:06 CEST 2005
Author: cfbolz
Date: Sat Jul 30 01:08:05 2005
New Revision: 15390
Modified:
pypy/dist/pypy/rpython/llinterp.py
pypy/dist/pypy/rpython/test/test_llinterp.py
Log:
added abs_int_ovf as well. There's probably more coming...
Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py (original)
+++ pypy/dist/pypy/rpython/llinterp.py Sat Jul 30 01:08:05 2005
@@ -342,6 +342,14 @@
assert type(b) is r_uint
return intmask(b)
+ def op_int_floordiv_ovf_zer(self, a, b):
+ assert type(a) is int
+ assert type(b) is int
+ if b == 0:
+ self.make_llexception(ZeroDivisionError())
+ return self.op_int_floordiv_ovf(a, b)
+
+
def op_float_floor(self, b):
assert type(b) is float
return math.floor(b)
@@ -435,7 +443,7 @@
if typ is int:
opname += '_ovf'
exec py.code.Source("""
- def op_%(opnameprefix)s_%(opname)s_ovf(self, x):
+ def op_%(opnameprefix)s_%(opname)s(self, x):
assert isinstance(x, %(typname)s)
func = opimpls[%(opname)r]
try:
@@ -443,7 +451,7 @@
except OverflowError, e:
self.make_llexception(e)
""" % locals()).compile()
- funcname = "op_%(opnameprefix)s_%(opname)s_ovf" % locals()
+ funcname = "op_%(opnameprefix)s_%(opname)s" % locals()
setattr(LLFrame, funcname, globals()[funcname])
Modified: pypy/dist/pypy/rpython/test/test_llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_llinterp.py (original)
+++ pypy/dist/pypy/rpython/test/test_llinterp.py Sat Jul 30 01:08:05 2005
@@ -278,6 +278,22 @@
assert res == 42
res = interpret(g, [-15])
assert res == 15
+
+def test_ovf_zer():
+ import sys
+ def f(x):
+ try:
+ return ovfcheck((-sys.maxint - 1) // x)
+ except OverflowError:
+ return 1
+ except ZeroDivisionError:
+ return 0
+ res = interpret(f, [0])
+ assert res == 0
+ res = interpret(f, [-1])
+ assert res == 1
+ res = interpret(f, [30])
+ assert res == (-sys.maxint - 1) // 30
def test_obj_obj_is():
More information about the Pypy-commit
mailing list