[pypy-svn] r30215 - in pypy/dist/pypy/translator/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Wed Jul 19 12:00:17 CEST 2006


Author: antocuni
Date: Wed Jul 19 12:00:14 2006
New Revision: 30215

Modified:
   pypy/dist/pypy/translator/cli/database.py
   pypy/dist/pypy/translator/cli/test/runtest.py
   pypy/dist/pypy/translator/cli/test/test_constant.py
Log:
Don't use float('inf') and float('nan') on windows.



Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py	(original)
+++ pypy/dist/pypy/translator/cli/database.py	Wed Jul 19 12:00:14 2006
@@ -31,6 +31,9 @@
 def isnan(v):
 	return v != v*1.0 or (v == 1.0 and v == 2.0)
 
+def isinf(v):
+    return v!=0 and (v == v*2)
+
 class LowLevelDatabase(object):
     def __init__(self, type_system_class = CTS, opcode_dict = opcodes, function_class = Function):
         self._pending_nodes = set()
@@ -235,7 +238,7 @@
         elif TYPE is ootype.Char or TYPE is ootype.UniChar:
             ilasm.opcode('ldc.i4', ord(value))
         elif TYPE is ootype.Float:
-            if value == float('inf'):
+            if isinf(value):
                 ilasm.opcode('ldc.r8', '(00 00 00 00 00 00 f0 7f)')
             elif isnan(value):
                 ilasm.opcode('ldc.r8', '(00 00 00 00 00 00 f8 ff)')

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	Wed Jul 19 12:00:14 2006
@@ -1,5 +1,6 @@
 import os
 import subprocess
+import platform
 
 import py
 from pypy.tool.udir import udir
@@ -230,7 +231,11 @@
             self._ann = ann
             self._cli_func = compile_function(fn, ann)
             return self._cli_func
-    
+
+    def _skip_win(self, reason):
+        if platform.system() == 'Windows':
+            py.test.skip('Windows --> %s' % reason)
+
     def interpret(self, fn, args, annotation=None):
         f = self._compile(fn, args, annotation)
         res = f(*args)

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	Wed Jul 19 12:00:14 2006
@@ -75,6 +75,7 @@
         assert self.interpret(fn, []) == 3
 
     def test_float_special(self):
+        self._skip_win('inf & nan')
         c = [float("inf"), float("nan")]
         def fn(i):
             return c[i]*2 == c[i]



More information about the Pypy-commit mailing list