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

ericvrp at codespeak.net ericvrp at codespeak.net
Mon Jul 4 20:57:54 CEST 2005


Author: ericvrp
Date: Mon Jul  4 20:57:52 2005
New Revision: 14247

Modified:
   pypy/dist/pypy/translator/llvm2/genllvm.py
   pypy/dist/pypy/translator/llvm2/structnode.py
   pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
Log:
Fixed import problem that occured when tested functions have identical names in different tests. In this case only the first test was used.
Fixed some typos


Modified: pypy/dist/pypy/translator/llvm2/genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm2/genllvm.py	Mon Jul  4 20:57:52 2005
@@ -13,6 +13,8 @@
 from pypy.translator.llvm2.codewriter import CodeWriter
 from pypy.translator.backendoptimization import remove_void
 
+function_count = {}
+
 def genllvm(translator):
     remove_void(translator)
     func = translator.entrypoint
@@ -51,17 +53,24 @@
         typ_decl.writeimpl(codewriter)
 
     comment("End of file") ; nl()
+
+    if func.func_name in function_count:
+        postfix = '_%d' % function_count[func.func_name]
+        function_count[func.func_name] += 1
+    else:
+        postfix = ''
+        function_count[func.func_name] = 1
     
     targetdir = udir
-    llvmsource = targetdir.join(func.func_name).new(ext='.ll')
+    llvmsource = targetdir.join(func.func_name+postfix).new(ext='.ll')
     content = str(codewriter) 
     llvmsource.write(content) 
     log.source(content)
   
     if not llvm_is_on_path(): 
         py.test.skip("llvm not found")  # XXX not good to call py.test.skip here
-         
-    pyxsource = llvmsource.new(basename=llvmsource.purebasename+'_wrapper'+'.pyx')
+
+    pyxsource = llvmsource.new(basename=llvmsource.purebasename+'_wrapper'+postfix+'.pyx')
     write_pyx_wrapper(entrynode, pyxsource)    
     
     return build_llvm_module.make_module_from_llvm(llvmsource, pyxsource)

Modified: pypy/dist/pypy/translator/llvm2/structnode.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/structnode.py	(original)
+++ pypy/dist/pypy/translator/llvm2/structnode.py	Mon Jul  4 20:57:52 2005
@@ -58,7 +58,7 @@
         codewriter.label("block0")
         indices_to_array = [("int", 0)]
         s = self.struct
-        while isintance(s, lltypes.Struct):
+        while isinstance(s, lltype.Struct):
             last_pos = len(self.struct._names_without_voids()) - 1
             indices_to_array.append(("uint", last_pos))
             s = s._flds.values()[-1]

Modified: pypy/dist/pypy/translator/llvm2/test/test_genllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm2/test/test_genllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm2/test/test_genllvm.py	Mon Jul  4 20:57:52 2005
@@ -41,22 +41,24 @@
     if not use_boehm_gc:
         py.test.skip("test_GC_malloc skipped because Boehm collector library was not found")
         return
-    def tuple_getitem2(n): 
-        x = 0
+    def tuple_getitem(n): 
+        x = 666
         i = 0
         while i < n:
-            l = (1,2,i,234,23,23,23,234,234,234,234)
+            l = (1,2,i,4,5,6,7,8,9,10,11)
             x += l[2]
             i += 1
         return x
-    mod,f = compile_module_function(tuple_getitem2, [int])
-    assert f(10000) == 49995000
+    mod,f = compile_module_function(tuple_getitem, [int])
+    n = 5000
+    result = tuple_getitem(n)
+    assert f(n) == result
     get_heap_size = getattr(mod, "GC_get_heap_size_wrapper")
     heap_size_start = get_heap_size()
-    for i in range(0,10):
-        assert f(10000) == 49995000
+    for i in range(0,25):
+        assert f(n) == result
         heap_size_inc = get_heap_size() - heap_size_start
-        assert heap_size_inc < 100000
+        assert heap_size_inc < 500000
 
 def test_return1():
     def simple1():
@@ -213,10 +215,10 @@
     
 def test_tuple_getitem(): 
     def tuple_getitem(i): 
-        l = (1,2,i)
+        l = (4,5,i)
         return l[1]
     f = compile_function(tuple_getitem, [int])
-    assert f(1) == 2 
+    assert f(1) == tuple_getitem(1)
 
 def test_nested_tuple():
     def nested_tuple(i): 



More information about the Pypy-commit mailing list