Author: Ronan Lamy <[email protected]>
Branch: kill-ootype
Changeset: r65257:4a56712ac399
Date: 2013-07-07 16:45 +0200
http://bitbucket.org/pypy/pypy/changeset/4a56712ac399/

Log:    fix rpython/translator/

diff --git a/rpython/translator/test/test_exceptiontransform.py 
b/rpython/translator/test/test_exceptiontransform.py
--- a/rpython/translator/test/test_exceptiontransform.py
+++ b/rpython/translator/test/test_exceptiontransform.py
@@ -26,8 +26,12 @@
         _already_transformed[t] = True
     return interp.eval_graph(graph, values)
 
-class BaseTestExceptionTransform:
-    type_system = None
+class TestExceptionTransform:
+    type_system = 'lltype'
+
+    def compile(self, fn, inputargs):
+        from rpython.translator.c.test.test_genc import compile
+        return compile(fn, inputargs)
 
     def transform_func(self, fn, inputtypes, backendopt=False):
         t = TranslationContext()
@@ -45,9 +49,6 @@
             t.view()
         return t, g
 
-    def compile(self, fn, inputargs):
-        raise NotImplementedError
-    
     def test_simple(self):
         def one():
             return 1
@@ -57,7 +58,7 @@
             return one()
 
         t, g = self.transform_func(foo, [])
-        assert len(list(g.iterblocks())) == 2 # graph does not change 
+        assert len(list(g.iterblocks())) == 2 # graph does not change
         result = interpret(foo, [])
         assert result == 1
         f = self.compile(foo, [])
@@ -176,7 +177,7 @@
         t.buildrtyper(type_system=self.type_system).specialize()
         g = graphof(t, f)
         etrafo = exceptiontransform.ExceptionTransformer(t)
-        etrafo.create_exception_handling(g)    
+        etrafo.create_exception_handling(g)
         assert etrafo.raise_analyzer.analyze_direct_call(g)
 
     def test_reraise_is_not_raise(self):
@@ -207,14 +208,6 @@
         result = f(1)
         assert result == -42
 
-
-class TestLLType(BaseTestExceptionTransform):
-    type_system = 'lltype'
-
-    def compile(self, fn, inputargs):
-        from rpython.translator.c.test.test_genc import compile
-        return compile(fn, inputargs)
-
     def test_needs_keepalive(self):
         check_debug_build()
         from rpython.rtyper.lltypesystem import lltype
@@ -279,11 +272,3 @@
         f = self.compile(foo, [])
         res = f()
         assert res == 42
-
-
-class TestOOType(BaseTestExceptionTransform):
-    type_system = 'ootype'
-
-    def compile(self, fn, inputargs):
-        from rpython.translator.cli.test.runtest import compile_function
-        return compile_function(fn, inputargs, auto_raise_exc=True, 
exctrans=True)
diff --git a/rpython/translator/test/test_interactive.py 
b/rpython/translator/test/test_interactive.py
--- a/rpython/translator/test/test_interactive.py
+++ b/rpython/translator/test/test_interactive.py
@@ -9,7 +9,7 @@
     t = Translation(f, [int, int])
     assert t.context is t.driver.translator
     assert t.config is t.driver.config is t.context.config
-    
+
     s = t.annotate()
     assert s.knowntype == int
 
@@ -27,7 +27,7 @@
     t.annotate()
     t.rtype()
 
-    assert 'rtype_lltype' in t.driver.done    
+    assert 'rtype_lltype' in t.driver.done
 
 def test_simple_backendopt():
     def f(x, y):
@@ -35,7 +35,7 @@
 
     t = Translation(f, [int, int], backend='c')
     t.backendopt()
-    
+
     assert 'backendopt_lltype' in t.driver.done
 
 def test_simple_source():
@@ -53,7 +53,7 @@
 
     t = Translation(f, [int, int])
     py.test.raises(Exception, "t.source()")
-    
+
 def test_disable_logic():
 
     def f(x,y):
@@ -67,7 +67,7 @@
 
 def test_simple_compile_c():
     import ctypes
-    
+
     def f(x,y):
         return x+y
 
@@ -87,28 +87,7 @@
     t = Translation(f, [int, int])
     t.rtype(type_system='lltype')
 
-    assert 'rtype_lltype' in t.driver.done    
-
-    t = Translation(f, [int, int])
-    t.rtype(type_system='ootype')
-    assert 'rtype_ootype' in t.driver.done        
-
-    t = Translation(f, [int, int], type_system='ootype')
-    t.rtype()
-    assert 'rtype_ootype' in t.driver.done    
-
-    t = Translation(f, [int, int])
-    t.rtype(backend='cli')
-    assert 'rtype_ootype' in t.driver.done
-
-
-    t = Translation(f, [int, int], backend='cli', type_system='ootype')
-    t.rtype()
-    assert 'rtype_ootype' in t.driver.done        
-
-    t = Translation(f, [int, int], type_system='lltype')
-    t.annotate()
-    py.test.raises(Exception, "t.rtype(backend='cli')")
+    assert 'rtype_lltype' in t.driver.done
 
     t = Translation(f, [int, int], backend='cli')
     t.annotate()
diff --git a/rpython/translator/test/test_simplify.py 
b/rpython/translator/test/test_simplify.py
--- a/rpython/translator/test/test_simplify.py
+++ b/rpython/translator/test/test_simplify.py
@@ -164,7 +164,7 @@
         return l[j]
     def external_function():
         return os.system("ls")
-    graph, t = translate(list_basic_ops, [int, int], False) 
+    graph, t = translate(list_basic_ops, [int, int], False)
     for block in graph.iterblocks():
         for op in block.operations:
             if op.opname == "direct_call":
@@ -175,7 +175,7 @@
     # a call to a wrapper function which itself contains the
     # real call to a graph-less external ll function, so
     # we check recursively
-    graph, t = translate(external_function, [], False) 
+    graph, t = translate(external_function, [], False)
     found = []
     def walkgraph(graph):
         for block in graph.iterblocks():
@@ -196,7 +196,7 @@
 def test_huge_func():
     g = None
     gstring = "def g(x):\n%s%s" % ("    x = x + 1\n" * 1000, "    return x\n")
-    exec gstring 
+    exec gstring
     assert g(1) == 1001
     # does not crash: previously join_blocks would barf on this
     graph, t = translate(g, [int])
@@ -308,7 +308,7 @@
     def test_iterate_over_list(self):
         def wrap(elem):
             return elem
-        
+
         def f(i):
             new_l = []
             l = range(4)
@@ -324,7 +324,7 @@
             'getattr': 1,
             'simple_call': 3,
             })
-            
+
 
 class TestLLSpecializeListComprehension:
     typesystem = 'lltype'
@@ -442,7 +442,3 @@
         interp, graph = self.specialize(main, [int])
         res = interp.eval_graph(graph, [10])
         assert res == 5 * 17
-
-
-class TestOOSpecializeListComprehension(TestLLSpecializeListComprehension):
-   typesystem = 'ootype'
diff --git a/rpython/translator/test/test_unsimplify.py 
b/rpython/translator/test/test_unsimplify.py
--- a/rpython/translator/test/test_unsimplify.py
+++ b/rpython/translator/test/test_unsimplify.py
@@ -26,7 +26,7 @@
         interp = LLInterpreter(t.rtyper)
         result = interp.eval_graph(graph, [1, 2])
         assert result == 5
-    
+
 def test_split_blocks_conditional():
     for i in range(3):
         def f(x, y):
@@ -73,38 +73,38 @@
 
 def test_call_initial_function():
     tmpfile = str(udir.join('test_call_initial_function'))
-    for type_system in ['lltype', 'ootype']:
-        def f(x):
-            return x * 6
-        def hello_world():
-            if we_are_translated():
-                fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
-                os.close(fd)
-        graph, t = translate(f, [int], type_system)
-        call_initial_function(t, hello_world)
-        #
-        if os.path.exists(tmpfile):
-            os.unlink(tmpfile)
-        interp = LLInterpreter(t.rtyper)
-        result = interp.eval_graph(graph, [7])
-        assert result == 42
-        assert os.path.isfile(tmpfile)
+    type_system = 'lltype'
+    def f(x):
+        return x * 6
+    def hello_world():
+        if we_are_translated():
+            fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
+            os.close(fd)
+    graph, t = translate(f, [int], type_system)
+    call_initial_function(t, hello_world)
+    #
+    if os.path.exists(tmpfile):
+        os.unlink(tmpfile)
+    interp = LLInterpreter(t.rtyper)
+    result = interp.eval_graph(graph, [7])
+    assert result == 42
+    assert os.path.isfile(tmpfile)
 
 def test_call_final_function():
     tmpfile = str(udir.join('test_call_final_function'))
-    for type_system in ['lltype', 'ootype']:
-        def f(x):
-            return x * 6
-        def goodbye_world():
-            if we_are_translated():
-                fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
-                os.close(fd)
-        graph, t = translate(f, [int], type_system)
-        call_final_function(t, goodbye_world)
-        #
-        if os.path.exists(tmpfile):
-            os.unlink(tmpfile)
-        interp = LLInterpreter(t.rtyper)
-        result = interp.eval_graph(graph, [7])
-        assert result == 42
-        assert os.path.isfile(tmpfile)
+    type_system = 'lltype'
+    def f(x):
+        return x * 6
+    def goodbye_world():
+        if we_are_translated():
+            fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
+            os.close(fd)
+    graph, t = translate(f, [int], type_system)
+    call_final_function(t, goodbye_world)
+    #
+    if os.path.exists(tmpfile):
+        os.unlink(tmpfile)
+    interp = LLInterpreter(t.rtyper)
+    result = interp.eval_graph(graph, [7])
+    assert result == 42
+    assert os.path.isfile(tmpfile)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to