[pypy-svn] r40534 - in pypy/dist/pypy: rpython/test translator/cli translator/cli/test
antocuni at codespeak.net
antocuni at codespeak.net
Thu Mar 15 15:13:09 CET 2007
Author: antocuni
Date: Thu Mar 15 15:13:06 2007
New Revision: 40534
Modified:
pypy/dist/pypy/rpython/test/test_rfloat.py
pypy/dist/pypy/rpython/test/tool.py
pypy/dist/pypy/translator/cli/opcodes.py
pypy/dist/pypy/translator/cli/test/runtest.py
pypy/dist/pypy/translator/cli/test/test_runtest.py
Log:
add cast_float_to_longlong support to gencli, and fix the tests.
Modified: pypy/dist/pypy/rpython/test/test_rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rfloat.py (original)
+++ pypy/dist/pypy/rpython/test/test_rfloat.py Thu Mar 15 15:13:06 2007
@@ -66,7 +66,7 @@
res = self.interpret(fn, [1.0])
assert res == 1
- assert type(res) is r_longlong
+ assert self.is_of_type(res, r_longlong)
res = self.interpret(fn, [2.34])
assert res == fn(2.34)
big = float(0x7fffffffffffffff)
Modified: pypy/dist/pypy/rpython/test/tool.py
==============================================================================
--- pypy/dist/pypy/rpython/test/tool.py (original)
+++ pypy/dist/pypy/rpython/test/tool.py Thu Mar 15 15:13:06 2007
@@ -19,6 +19,9 @@
def float_eq(self, x, y):
return x == y
+ def is_of_type(self, x, type_):
+ return type(x) is type_
+
def _skip_oo(self, reason):
if self.type_system == 'ootype':
py.test.skip("ootypesystem doesn't support %s, yet" % reason)
Modified: pypy/dist/pypy/translator/cli/opcodes.py
==============================================================================
--- pypy/dist/pypy/translator/cli/opcodes.py (original)
+++ pypy/dist/pypy/translator/cli/opcodes.py Thu Mar 15 15:13:06 2007
@@ -225,6 +225,7 @@
'cast_float_to_int': 'conv.i4',
'cast_float_to_uint': 'conv.u4',
'cast_longlong_to_float': 'conv.r8',
+ 'cast_float_to_longlong': 'conv.i8',
'truncate_longlong_to_int': 'conv.i4',
}
Modified: pypy/dist/pypy/translator/cli/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/runtest.py (original)
+++ pypy/dist/pypy/translator/cli/test/runtest.py Thu Mar 15 15:13:06 2007
@@ -23,7 +23,7 @@
from pypy.translator.cli.entrypoint import BaseEntryPoint
from pypy.translator.cli.support import patch, unpatch
-FLOAT_PRECISION = 10
+FLOAT_PRECISION = 8
def check(func, annotation, args):
mono = compile_function(func, annotation)
@@ -50,7 +50,7 @@
This class produces a 'main' method that converts its arguments
to int32, pass them to another method and prints out the result.
"""
-
+
def __init__(self, graph_to_call, wrap_exceptions=False):
self.graph = graph_to_call
self.wrap_exceptions = wrap_exceptions
@@ -290,6 +290,9 @@
diff = abs(x-y)
return diff/x < 10**-FLOAT_PRECISION
+ def is_of_type(self, x, type_):
+ return True # we can't really test the type
+
def ll_to_string(self, s):
return s
Modified: pypy/dist/pypy/translator/cli/test/test_runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_runtest.py (original)
+++ pypy/dist/pypy/translator/cli/test/test_runtest.py Thu Mar 15 15:13:06 2007
@@ -26,7 +26,7 @@
def test_float(self):
x = 10/3.0
res = self.interpret(ident, [x])
- assert round(x, FLOAT_PRECISION) == round(res, FLOAT_PRECISION)
+ assert self.float_eq(x, res)
def test_char(self):
assert self.interpret(ident, ['a']) == 'a'
More information about the Pypy-commit
mailing list