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

arigo at codespeak.net arigo at codespeak.net
Sat Apr 2 17:15:27 CEST 2005


Author: arigo
Date: Sat Apr  2 17:15:26 2005
New Revision: 10251

Modified:
   pypy/dist/pypy/translator/genc_funcdef.py
   pypy/dist/pypy/translator/test/test_ctrans.py
Log:
The genc+typer tests work if we disable the op_simple_call() shortcut.
This shortcut was a hack anyway: it should be reintroduced as a
specialization in typer.py.



Modified: pypy/dist/pypy/translator/genc_funcdef.py
==============================================================================
--- pypy/dist/pypy/translator/genc_funcdef.py	(original)
+++ pypy/dist/pypy/translator/genc_funcdef.py	Sat Apr  2 17:15:26 2005
@@ -443,30 +443,30 @@
         args.insert(0, '%d' % len(args))
         return 'OP_NEWTUPLE((%s), %s, %s)' % (', '.join(args), r, err)
 
-    def fast_simple_call(self, args, r, err):
-        # try to generate a SIMPLE_CALL using a shortcut:
-        # a direct call to the ff_xxx() function, using its C signature.
-        if USE_CALL_TRACE:
-            return None
-        target = args[0].args[0]
-        args = [arg.compute() for arg in args[1:]]
-        if not isinstance(target, Constant):
-            return None
-        if not isinstance(target.value, FunctionType):
-            return None
-        funcdef = self.genc.getfuncdef(target.value)
-        if funcdef is None:
-            return None
-        if len(funcdef.graphargs) != len(args) or funcdef.vararg:
-            return None
-        return 'if (!(%s=%s(%s))) FAIL(%s);' % (
-            r, funcdef.fast_name, ', '.join(args), err)
+##    def fast_simple_call(self, args, r, err):
+##        # try to generate a SIMPLE_CALL using a shortcut:
+##        # a direct call to the ff_xxx() function, using its C signature.
+##        if USE_CALL_TRACE:
+##            return None
+##        target = args[0].args[0]
+##        args = [arg.compute() for arg in args[1:]]
+##        if not isinstance(target, Constant):
+##            return None
+##        if not isinstance(target.value, FunctionType):
+##            return None
+##        funcdef = self.genc.getfuncdef(target.value)
+##        if funcdef is None:
+##            return None
+##        if len(funcdef.graphargs) != len(args) or funcdef.vararg:
+##            return None
+##        return 'if (!(%s=%s(%s))) FAIL(%s);' % (
+##            r, funcdef.fast_name, ', '.join(args), err)
 
     def OP_SIMPLE_CALL(self, args, r, err):
-        result = self.fast_simple_call(args, r, err)
-        if result is not None:
-            return result
-        # fall-back
+##        result = self.fast_simple_call(args, r, err)
+##        if result is not None:
+##            return result
+##        # fall-back
         args = [arg.compute() for arg in args]
         args.append('NULL')
         return 'OP_SIMPLE_CALL((%s), %s, %s)' % (', '.join(args), r, err)

Modified: pypy/dist/pypy/translator/test/test_ctrans.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_ctrans.py	(original)
+++ pypy/dist/pypy/translator/test/test_ctrans.py	Sat Apr  2 17:15:26 2005
@@ -1,5 +1,5 @@
 import autopath
-import py
+import py, sys
 from pypy.tool.udir import udir
 from pypy.translator.genc import GenC
 from pypy.translator.typer import GenCSpecializer
@@ -306,7 +306,7 @@
         assert result == ([3, 'c'], [9], [11, 'h'])
 
     def test_slice_long(self):
-        def slice_long(l=list, n=int):
+        def slice_long(l=list, n=long):
             return l[:n]
         fn = self.getcompiled(slice_long)
         l = list('abc')
@@ -316,7 +316,7 @@
         assert result == list('abc')
 
 
-class IN_PROGRESS_TestTypedTestCase(TestAnnotatedTestCase):
+class TestTypedTestCase(TestAnnotatedTestCase):
 
     def getcompiled(self, func):
         t = Translator(func, simplifying=True)
@@ -332,3 +332,7 @@
         GenCSpecializer(a).specialize()
         t.checkgraphs()
         return skip_missing_compiler(t.ccompile)
+
+    def test_int_overflow(self):
+        fn = self.getcompiled(snippet.simple_func)
+        raises(OverflowError, fn, sys.maxint+1)



More information about the Pypy-commit mailing list