[pypy-commit] pypy kill-someobject: fix test_interactive

fijal noreply at buildbot.pypy.org
Wed Oct 10 11:12:59 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: kill-someobject
Changeset: r57964:b55b47d177f4
Date: 2012-10-10 11:12 +0200
http://bitbucket.org/pypy/pypy/changeset/b55b47d177f4/

Log:	fix test_interactive

diff --git a/pypy/bin/translatorshell.py b/pypy/bin/translatorshell.py
--- a/pypy/bin/translatorshell.py
+++ b/pypy/bin/translatorshell.py
@@ -8,10 +8,10 @@
 
 Example:
 
-    t = Translation(func)
+    t = Translation(func, [int])       # pass the list of args types
     t.view()                           # control flow graph
 
-    t.annotate([int])                  # pass the list of args types
+    t.annotate()
     t.view()                           # graph + annotations under the mouse
 
     t.rtype()                          # use low level operations 
diff --git a/pypy/doc/getting-started-dev.rst b/pypy/doc/getting-started-dev.rst
--- a/pypy/doc/getting-started-dev.rst
+++ b/pypy/doc/getting-started-dev.rst
@@ -27,7 +27,7 @@
 ``pypy/translator/test/snippet.py``, which is imported under the name
 ``snippet``.  For example::
 
-    >>> t = Translation(snippet.is_perfect_number)
+    >>> t = Translation(snippet.is_perfect_number, [int])
     >>> t.view()
         
 After that, the graph viewer pops up, that lets you interactively inspect the
@@ -40,7 +40,7 @@
 We have a type annotator that can completely infer types for functions like
 ``is_perfect_number`` (as well as for much larger examples)::
 
-    >>> t.annotate([int])
+    >>> t.annotate()
     >>> t.view()
 
 Move the mouse over variable names (in red) to see their inferred types.
@@ -74,8 +74,8 @@
 
     >>> def myfunc(a, b): return a+b
     ... 
-    >>> t = Translation(myfunc)
-    >>> t.annotate([int, int])
+    >>> t = Translation(myfunc, [int, int])
+    >>> t.annotate()
     >>> f = t.compile_cli() # or compile_jvm()
     >>> f(4, 5)
     9
diff --git a/pypy/translator/backendopt/test/test_escape.py b/pypy/translator/backendopt/test/test_escape.py
--- a/pypy/translator/backendopt/test/test_escape.py
+++ b/pypy/translator/backendopt/test/test_escape.py
@@ -5,11 +5,9 @@
 from pypy.rlib.objectmodel import instantiate
 from pypy import conftest
 
-import py
-
 def build_adi(function, types):
-    t = Translation(function)
-    t.rtype(types)
+    t = Translation(function, types)
+    t.rtype()
     if conftest.option.view:
         t.view()
     adi = AbstractDataFlowInterpreter(t.context)
diff --git a/pypy/translator/c/test/test_symbolic.py b/pypy/translator/c/test/test_symbolic.py
--- a/pypy/translator/c/test/test_symbolic.py
+++ b/pypy/translator/c/test/test_symbolic.py
@@ -4,8 +4,8 @@
 from pypy.rlib.objectmodel import ComputedIntSymbolic
 
 def getcompiled(f, args):
-    t = Translation(f)
-    fn = t.compile_c(args)
+    t = Translation(f, args)
+    fn = t.compile_c()
     if conftest.option.view:
         t.view()
     return fn, t
diff --git a/pypy/translator/test/test_interactive.py b/pypy/translator/test/test_interactive.py
--- a/pypy/translator/test/test_interactive.py
+++ b/pypy/translator/test/test_interactive.py
@@ -10,20 +10,13 @@
     assert t.context is t.driver.translator
     assert t.config is t.driver.config is t.context.config
     
-    s = t.annotate([int, int])
+    s = t.annotate()
     assert s.knowntype == int
 
     t = Translation(f, [int, int])
     s = t.annotate()
     assert s.knowntype == int
 
-    t = Translation(f)
-    s = t.annotate([int, int])
-    assert s.knowntype == int
-
-    t = Translation(f, [int, int])
-    py.test.raises(Exception, "t.annotate([int, float])")
-
 
 def test_simple_rtype():
 
@@ -31,17 +24,11 @@
         return x+y
 
     t = Translation(f, [int, int])
-    s = t.annotate()
+    t.annotate()
     t.rtype()
 
     assert 'rtype_lltype' in t.driver.done    
 
-    t = Translation(f)
-    s = t.annotate([int, int])
-    t.rtype()
-
-    assert 'rtype_lltype' in t.driver.done        
-
 def test_simple_backendopt():
     def f(x, y):
         return x,y
@@ -51,17 +38,12 @@
     
     assert 'backendopt_lltype' in t.driver.done
 
-    t = Translation(f, [int, int])
-    t.backendopt()
-
-    assert 'backendopt_lltype' in t.driver.done
-
 def test_simple_source():
     def f(x, y):
         return x,y
 
-    t = Translation(f, backend='c')
-    t.annotate([int, int])
+    t = Translation(f, [int, int], backend='c')
+    t.annotate()
     t.source()
     assert 'source_c' in t.driver.done
 
@@ -84,39 +66,18 @@
     assert 'backendopt' not in t.driver.done
 
 def test_simple_compile_c():
+    import ctypes
+    
     def f(x,y):
         return x+y
 
     t = Translation(f, [int, int])
     t.source(backend='c')
-    t_f = t.compile()
+    t.compile()
 
-    res = t_f(2,3)
-    assert res == 5
-
-    t = Translation(f, [int, int])
-    t_f = t.compile_c()
-
-    res = t_f(2,3)
-    assert res == 5
-
-def test_simple_compile_c_isolate():
-    from pypy.tool import isolate
-    
-    def f(x,y):
-        return x+y
-
-    t = Translation(f, [int, int])
-    t.set_backend_extra_options(c_isolated=True)
-    t_f = t.compile()
-
-    assert isinstance(t_f, isolate.IsolateInvoker)
-
-    res = t_f(2,3)
-    assert res == 5
-
-    # cleanup
-    t_f.close_isolate()
+    dll = ctypes.CDLL(str(t.driver.c_entryp))
+    f = dll.pypy_g_f
+    assert f(2, 3) == 5
 
 def test_simple_rtype_with_type_system():
 
@@ -124,37 +85,32 @@
         return x+y
 
     t = Translation(f, [int, int])
-    s = t.annotate()
     t.rtype(type_system='lltype')
 
     assert 'rtype_lltype' in t.driver.done    
 
     t = Translation(f, [int, int])
-    s = t.annotate()
     t.rtype(type_system='ootype')
     assert 'rtype_ootype' in t.driver.done        
 
-    t = Translation(f, type_system='ootype')
-    s = t.annotate([int, int])
+    t = Translation(f, [int, int], type_system='ootype')
     t.rtype()
     assert 'rtype_ootype' in t.driver.done    
 
-    t = Translation(f)
-    s = t.annotate([int, int])
+    t = Translation(f, [int, int])
     t.rtype(backend='cli')
     assert 'rtype_ootype' in t.driver.done
 
 
-    t = Translation(f, backend='cli', type_system='ootype')
-    s = t.annotate([int, int])
+    t = Translation(f, [int, int], backend='cli', type_system='ootype')
     t.rtype()
     assert 'rtype_ootype' in t.driver.done        
 
-    t = Translation(f, type_system='lltype')
-    s = t.annotate([int, int])
+    t = Translation(f, [int, int], type_system='lltype')
+    t.annotate()
     py.test.raises(Exception, "t.rtype(backend='cli')")
 
-    t = Translation(f, backend='cli')
-    s = t.annotate([int, int])
+    t = Translation(f, [int, int], backend='cli')
+    t.annotate()
     py.test.raises(Exception, "t.rtype(type_system='lltype')")
 


More information about the pypy-commit mailing list