[pypy-svn] r13247 - in pypy/dist/pypy: bin translator/genc/test translator/test

arigo at codespeak.net arigo at codespeak.net
Thu Jun 9 22:36:46 CEST 2005


Author: arigo
Date: Thu Jun  9 22:36:42 2005
New Revision: 13247

Added:
   pypy/dist/pypy/translator/genc/test/inprogress_test_typed.py
      - copied unchanged from r13246, pypy/dist/pypy/translator/genc/test/test_typed.py
Removed:
   pypy/dist/pypy/translator/genc/test/test_typed.py
Modified:
   pypy/dist/pypy/bin/translator.py
   pypy/dist/pypy/translator/test/test_backends.py
Log:
Final adjustements and end of the merge.

The Translator class uses now the new 'c' translator.
To run the rtyper, use the method 'specialize()' of the Translator
(which used to be defined on the annotator.)

Renamed test file while in progress.



Modified: pypy/dist/pypy/bin/translator.py
==============================================================================
--- pypy/dist/pypy/bin/translator.py	(original)
+++ pypy/dist/pypy/bin/translator.py	Thu Jun  9 22:36:42 2005
@@ -24,7 +24,7 @@
     t.call(arg)                        # call original function
     t.dis()                            # bytecode disassemble
 
-    a.specialize()                     # use low level operations (for C only)
+    t.specialize()                     # use low level operations (for C only)
     f = t.ccompile()                   # C compilation
     f = t.llvmcompile()                # LLVM compilation
     assert f(arg) == t.call(arg)       # sanity check

Deleted: /pypy/dist/pypy/translator/genc/test/test_typed.py
==============================================================================
--- /pypy/dist/pypy/translator/genc/test/test_typed.py	Thu Jun  9 22:36:42 2005
+++ (empty file)
@@ -1,91 +0,0 @@
-import autopath
-import sys
-import py.test
-from pypy.translator.translator import Translator
-from pypy.translator.test import snippet 
-from pypy.translator.tool.buildpyxmodule import skip_missing_compiler
-
-from pypy.translator.genc.test.test_annotated import TestAnnotatedTestCase as _TestAnnotatedTestCase
-
-
-class TestTypedTestCase(_TestAnnotatedTestCase):
-
-    def getcompiled(self, func):
-        t = Translator(func, simplifying=True)
-        # builds starting-types from func_defs 
-        argstypelist = []
-        if func.func_defaults:
-            for spec in func.func_defaults:
-                if isinstance(spec, tuple):
-                    spec = spec[0] # use the first type only for the tests
-                argstypelist.append(spec)
-        a = t.annotate(argstypelist)
-        a.simplify()
-        t.specialize()
-        t.checkgraphs()
-        return skip_missing_compiler(t.ccompile)
-
-    def test_call_five(self):
-        # --  the result of call_five() isn't a real list, but an rlist
-        #     that can't be converted to a PyListObject
-        def wrapper():
-            lst = snippet.call_five()
-            return len(lst), lst[0]
-        call_five = self.getcompiled(snippet.call_five)
-        result = call_five()
-        assert result == (1, 5)
-
-    def test_get_set_del_slice(self):
-        def get_set_del_nonneg_slice(l=list): # no neg slices for now!
-            del l[:1]
-            del l[len(l)-1:]
-            del l[2:4]
-            l[:1] = [3]
-            l[len(l)-1:] = [9]
-            l[2:4] = [8,11]
-            return l[:2], l[5:], l[3:5]        
-        fn = self.getcompiled(get_set_del_nonneg_slice)
-        l = list('abcdefghij')
-        result = fn(l)
-        assert l == [3, 'c', 8, 11, 'h', 9]
-        assert result == ([3, 'c'], [9], [11, 'h'])
-
-    def test_slice_long(self):
-        "the parent's test_slice_long() makes no sense here"
-
-    def test_int_overflow(self):
-        fn = self.getcompiled(snippet.add_func)
-        raises(OverflowError, fn, sys_maxint())
-
-    def test_int_div_ovf_zer(self): # 
-        py.test.skip("right now aborting python with Floating Point Error!")
-        fn = self.getcompiled(snippet.div_func)
-        raises(OverflowError, fn, -1)
-        raises(ZeroDivisionError, fn, 0)
-
-    def test_int_mod_ovf_zer(self):
-        py.test.skip("right now aborting python with Floating Point Error!")        
-        fn = self.getcompiled(snippet.mod_func)
-        raises(OverflowError, fn, -1)
-        raises(ZeroDivisionError, fn, 0)
-
-    def test_int_rshift_val(self):
-        fn = self.getcompiled(snippet.rshift_func)
-        raises(ValueError, fn, -1)
-
-    def test_int_lshift_ovf_val(self):
-        fn = self.getcompiled(snippet.lshift_func)
-        raises(ValueError, fn, -1)
-        raises(OverflowError, fn, 1)
-
-    def test_int_unary_ovf(self):
-        fn = self.getcompiled(snippet.unary_func)
-        for i in range(-3,3):
-            assert fn(i) == (-(i), abs(i-1))
-        raises (OverflowError, fn, -sys_maxint()-1)
-        raises (OverflowError, fn, -sys_maxint())
-
-def sys_maxint():
-    if sys.maxint != 2147483647:
-        py.test.skip("genc ovf incomplete: int might differ from long")
-    return sys.maxint

Modified: pypy/dist/pypy/translator/test/test_backends.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_backends.py	(original)
+++ pypy/dist/pypy/translator/test/test_backends.py	Thu Jun  9 22:36:42 2005
@@ -10,6 +10,7 @@
 
 
 backends = 'source c cl llvm pyrex'.split()
+deterministic_backends = 'source cl llvm pyrex'.split()
 functions = 'forty_two'.split() #XXX add more functions here when RPythonTyper can handle them
 
 regenerate_code = '''def test_regenerate_%(function)s_%(backend)s():
@@ -17,15 +18,15 @@
     t.simplify()
     a = t.annotate([])
     a.simplify()
-    typer = RPythonTyper(t.annotator)
-    typer.specialize()
+    t.specialize()
     first  = t.%(backend)s()
     second = t.%(backend)s()
-    if first != second:
-        print '<FIRST>\\n'  + first  + '\\n</FIRST>\\n'
-        print '<SECOND>\\n' + second + '\\n</SECOND>\\n'
-        #t.view()
-    assert first == second'''
+    if %(backend)r in deterministic_backends:
+        if first != second:
+            print '<FIRST>\\n'  + first  + '\\n</FIRST>\\n'
+            print '<SECOND>\\n' + second + '\\n</SECOND>\\n'
+            #t.view()
+        assert first == second'''
 
 for backend in backends:
     for function in functions:



More information about the Pypy-commit mailing list