[pypy-svn] r29701 - pypy/dist/pypy/translator/llvm/pyllvm/test
simonb at codespeak.net
simonb at codespeak.net
Thu Jul 6 18:59:54 CEST 2006
Author: simonb
Date: Thu Jul 6 18:59:52 2006
New Revision: 29701
Modified:
pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py
Log:
pyllvm tests working (simon & eric)
Modified: pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py (original)
+++ pypy/dist/pypy/translator/llvm/pyllvm/test/test_ee.py Thu Jul 6 18:59:52 2006
@@ -16,6 +16,8 @@
global ee
if ee is None:
ee = pyllvm.ExecutionEngine()
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def test_execution_engine_singleton():
make_execution_engine()
@@ -26,7 +28,12 @@
def test_load():
make_execution_engine()
ee.parse(codepath.join("hello.ll").read())
- ee.parse(codepath.join("addnumbers.ll").read())
+ ee.parse(codepath.join("addnumbers.ll").read()) # why does this work ?
+ ee.delete("hello")
+ ee.delete("gethellostr")
+ ee.delete("add")
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def test_functions():
make_execution_engine()
@@ -42,30 +49,43 @@
# assert len(args) == 0
py.test.raises(Exception, mod.n_functions, 1)
py.test.raises(Exception, mod.n_functions, "string")
+ ee.delete("hello")
+ ee.delete("gethellostr")
+ assert mod.n_functions() == 0
def test_call_parse_once():
make_execution_engine()
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
ee.parse(codepath.join("hello.ll").read())
f = ee.getModule().getNamedFunction
hello = f("hello")
gethellostr = f("gethellostr")
assert hello() == 0
assert gethellostr() == "hello world\n"
+ ee.delete("hello")
+ ee.delete("gethellostr")
+ assert mod.n_functions() == 0
def test_call_parse_twice():
py.test.skip("WIP")
make_execution_engine()
+ mod = ee.getModule()
ee.parse(codepath.join("hello.ll").read())
f = ee.getModule().getNamedFunction
f1 = f("gethellostr")
assert f1() == "hello world\n"
- ee.parse(codepath.join("addnumbers.ll").read())
+ ee.parse(codepath.join("addnumbers.ll").read()) # blows here
f2 = f("add")
assert f2(10, 32) == 42
assert f1() == "hello world\n"
py.test.raises(Exception, ee.parse)
py.test.raises(Exception, ee.parse, 1)
py.test.raises(Exception, ee.parse, "abc")
+ ee.delete("hello")
+ ee.delete("gethellostr")
+ ee.delete("add")
+ assert mod.n_functions() == 0
def test_call_between_parsed_code():
"""we parse add1 last on purpose to see if the JIT resolves
@@ -78,6 +98,10 @@
f = ee.getModule().getNamedFunction
assert f("add1")(41) == 42
assert f("calc")(122) == 123
+ ee.delete("calc")
+ ee.delete("add1")
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def test_replace_function():
py.test.skip("WIP")
@@ -93,6 +117,10 @@
ee.parse(ll_snippet.add1_version2, "add1")
assert f("add1")(42) == 142
assert f("calc")(142) == 242
+ ee.delete("calc")
+ ee.delete("add1")
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def test_share_data_between_parsed_code():
make_execution_engine()
@@ -104,9 +132,13 @@
assert f("sub10_from_global_int_a")() == 91
assert f("add1_to_global_int_a")() == 92
assert f("sub10_from_global_int_a")() == 82
+ ee.delete("add1_to_global_int_a")
+ ee.delete("sub10_from_global_int_a")
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def test_native_code(): #examine JIT generate native (assembly) code
- py.test.skip("WIP")
+# py.test.skip("WIP")
pyllvm.toggle_print_machineinstrs()
make_execution_engine()
ee.parse(ll_snippet.calc)
@@ -114,9 +146,12 @@
f = ee.getModule().getNamedFunction
assert f("calc")(41) == 42
pyllvm.toggle_print_machineinstrs()
+ ee.delete("calc")
+ ee.delete("add1")
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def test_delete_function(): #this will only work if nothing uses Fn of course!
- py.test.skip("WIP")
make_execution_engine()
mod = ee.getModule()
ee.parse(ll_snippet.calc)
@@ -134,6 +169,10 @@
ee.parse(ll_snippet.calc)
ee.parse(ll_snippet.add1)
assert f("calc")(100) == 101
+ ee.delete("calc")
+ ee.delete("add1")
+ mod = ee.getModule()
+ assert mod.n_functions() == 0
def TODOtest_multiple_executionengines():
pass
More information about the Pypy-commit
mailing list