Commits

Maciej Fijalkowski committed b55b47d

fix test_interactive

Comments (0)

Files changed (5)

pypy/bin/translatorshell.py

 
 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 

pypy/doc/getting-started-dev.rst

 ``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
 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.
 
     >>> 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

pypy/translator/backendopt/test/test_escape.py

 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)

pypy/translator/c/test/test_symbolic.py

 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

pypy/translator/test/test_interactive.py

     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():
 
         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
     
     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
 
     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():
 
         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')")