[pypy-svn] r49332 - in pypy/dist/pypy: rpython/test translator/cli/test translator/llvm/test

xoraxax at codespeak.net xoraxax at codespeak.net
Tue Dec 4 14:08:28 CET 2007


Author: xoraxax
Date: Tue Dec  4 14:08:27 2007
New Revision: 49332

Modified:
   pypy/dist/pypy/rpython/test/tool.py
   pypy/dist/pypy/translator/cli/test/runtest.py
   pypy/dist/pypy/translator/llvm/test/runtest.py
Log:
Reduce pointless code duplication, fix frexp tests on cli and llvm.

Modified: pypy/dist/pypy/rpython/test/tool.py
==============================================================================
--- pypy/dist/pypy/rpython/test/tool.py	(original)
+++ pypy/dist/pypy/rpython/test/tool.py	Tue Dec  4 14:08:27 2007
@@ -3,6 +3,8 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.test.test_llinterp import gengraph, interpret, interpret_raises
 
+FLOAT_PRECISION = 8
+
 class BaseRtypingTest(object):
 
     def gengraph(self, func, argtypes=[], viewbefore='auto', policy=None,
@@ -19,6 +21,10 @@
     def float_eq(self, x, y):
         return x == y
 
+    def float_eq_approx(self, x, y):
+        diff = abs(x-y)
+        return diff < 10**-FLOAT_PRECISION
+
     def is_of_type(self, x, type_):
         return type(x) is type_
 

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	Tue Dec  4 14:08:27 2007
@@ -23,7 +23,6 @@
 from pypy.translator.cli.entrypoint import BaseEntryPoint
 from pypy.translator.oosupport.support import patch_os, unpatch_os
 
-FLOAT_PRECISION = 8
 
 def format_object(TYPE, cts, ilasm):
     if TYPE is ootype.Void:
@@ -292,9 +291,7 @@
         else:
             assert False, 'function did raise no exception at all'
 
-    def float_eq(self, x, y):
-        diff = abs(x-y)
-        return diff/x < 10**-FLOAT_PRECISION
+    float_eq = BaseRtypingTest.float_eq_approx
 
     def is_of_type(self, x, type_):
         return True # we can't really test the type

Modified: pypy/dist/pypy/translator/llvm/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/test/runtest.py	(original)
+++ pypy/dist/pypy/translator/llvm/test/runtest.py	Tue Dec  4 14:08:27 2007
@@ -10,7 +10,6 @@
 optimize_tests = False
 native_llvm_backend = True
 MINIMUM_LLVM_VERSION = 2.0
-FLOAT_PRECISION = 8
 
 # prevents resource leaking
 use_isolate = True
@@ -219,10 +218,8 @@
             return True
         else:
             assert False, 'function did raise no exception at all'
-
-    def float_eq(self, x, y):
-        diff = abs(x-y)
-        return diff/x < 10**-FLOAT_PRECISION
+ 
+    float_eq = BaseRtypingTest.float_eq_approx
 
     def is_of_type(self, x, type_):
         return True # we can't really test the type



More information about the Pypy-commit mailing list