[pypy-svn] r30137 - in pypy/dist/pypy/translator/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Mon Jul 17 18:07:27 CEST 2006
Author: antocuni
Date: Mon Jul 17 18:07:22 2006
New Revision: 30137
Modified:
pypy/dist/pypy/translator/cli/database.py
pypy/dist/pypy/translator/cli/test/test_constant.py
Log:
Both the test and the nan detection was buggy. Thanks to mwh and
xorAxAx.
Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py (original)
+++ pypy/dist/pypy/translator/cli/database.py Mon Jul 17 18:07:22 2006
@@ -27,6 +27,9 @@
'[pypylib]pypy.runtime.Record_Float_Float'
}
+def isnan(v):
+ return v != v*1.0 or (v == 1.0 and v == 2.0)
+
class LowLevelDatabase(object):
def __init__(self, type_system_class = CTS, opcode_dict = opcodes, function_class = Function):
self._pending_nodes = set()
@@ -197,7 +200,7 @@
elif TYPE is ootype.Float:
if value == float('inf'):
ilasm.opcode('ldc.r8', '(00 00 00 00 00 00 f0 7f)')
- elif value == float('NaN'):
+ elif isnan(value):
ilasm.opcode('ldc.r8', '(00 00 00 00 00 00 f8 ff)')
else:
ilasm.opcode('ldc.r8', repr(value))
Modified: pypy/dist/pypy/translator/cli/test/test_constant.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_constant.py (original)
+++ pypy/dist/pypy/translator/cli/test/test_constant.py Mon Jul 17 18:07:22 2006
@@ -75,8 +75,10 @@
assert self.interpret(fn, []) == 3
def test_float_special(self):
- inf = float("inf")
- nan = float("nan")
- def fn():
- return inf*2 == inf and not (nan == nan)
- assert self.interpret(fn, []) == True
+ c = [float("inf"), float("nan")]
+ def fn(i):
+ return c[i]*2 == c[i]
+ def fn2(i):
+ return c[i] != c[i]
+ assert self.interpret(fn, [0]) == True
+ assert self.interpret(fn2, [1]) == True
More information about the Pypy-commit
mailing list