From aa5b969961b4390a2e68dab0d6c14b23c7e92933 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Wed, 6 Feb 2013 21:31:24 -0600 Subject: [PATCH] Expand test --- newbinding/test_binding.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/newbinding/test_binding.py b/newbinding/test_binding.py index 578c532..5b51ecb 100644 --- a/newbinding/test_binding.py +++ b/newbinding/test_binding.py @@ -82,8 +82,16 @@ def test_basic_jit_use(): errio = StringIO() print m - # build pass manager + # verifier + action = api.VerifierFailureAction.ReturnStatusAction + corrupted = api.verifyFunction(fn, action) + assert not corrupted + corrupted = api.verifyModule(m, action, errio) + print corrupted + assert not corrupted, errio.getvalue() + + # build pass manager pmb = api.PassManagerBuilder.new() pmb.OptLevel = 3 assert pmb.OptLevel == 3 @@ -156,6 +164,11 @@ def test_basic_jit_use(): m3.setModuleIdentifier(m.getModuleIdentifier()) assert str(m3) == str(m) + # test clone + m4 = api.CloneModule(m) + assert m4 is not m + assert str(m4) == str(m) + def test_engine_builder(): api.InitializeNativeTarget() context = api.getGlobalContext() @@ -286,6 +299,26 @@ def test_globalvariable(): print m.list_globals() + +def test_sequentialtypes(): + context = api.getGlobalContext() + int32ty = api.Type.getInt32Ty(context) + ary_int32x4 = api.ArrayType.get(int32ty, 4) + assert '[4 x i32]' == str(ary_int32x4) + ptr_int32 = api.PointerType.get(int32ty, 1) + assert 'i32 addrspace(1)*' == str(ptr_int32) + vec_int32x4 = api.VectorType.get(int32ty, 4) + assert '<4 x i32>' == str(vec_int32x4) + + +def test_constants(): + context = api.getGlobalContext() + int32ty = api.Type.getInt32Ty(context) + ary_int32x4 = api.ArrayType.get(int32ty, 4) + intconst = api.ConstantInt.get(int32ty, 123) + aryconst = api.ConstantArray.get(ary_int32x4, [intconst] * 4) + assert str(aryconst.getAggregateElement(0)) == str(intconst) + def main(): for name, value in globals().items(): if name.startswith('test_') and callable(value):