add constant expression test

This commit is contained in:
Ilan Schnell 2012-09-22 20:34:51 -05:00
commit 81d6da3ae5
2 changed files with 16 additions and 17 deletions

View file

@ -185,6 +185,22 @@ tests.append(TestAtomic)
# ---------------------------------------------------------------------------
class TestConstExpr(unittest.TestCase):
def test_constexpr_opcode(self):
mod = Module.new('test_constexpr_opcode')
func = mod.add_function(Type.function(Type.void(), []), name="foo")
builder = Builder.new(func.append_basic_block('entry'))
a = builder.inttoptr(Constant.int(Type.int(), 123),
Type.pointer(Type.int()))
self.assertTrue(isinstance(a, lc.ConstantExpr))
self.assertEqual(a.opcode, lc.OPCODE_INTTOPTR)
self.assertEqual(a.opcode_name, "inttoptr")
tests.append(TestConstExpr)
# ---------------------------------------------------------------------------
class TestOperands(unittest.TestCase):
# implement a test function
test_module = """

View file

@ -1,17 +0,0 @@
import unittest
from llvm.core import *
class TestConstExpr(unittest.TestCase):
def test_constexpr_opcode(self):
mod = Module.new('test_constexpr_opcode')
func = mod.add_function(Type.function(Type.void(), []), name="foo")
builder = Builder.new(func.append_basic_block('entry'))
a = builder.inttoptr(Constant.int(Type.int(), 123),
Type.pointer(Type.int()))
self.assertTrue(isinstance(a, ConstantExpr))
self.assertEqual(a.opcode, OPCODE_INTTOPTR)
self.assertEqual(a.opcode_name, "inttoptr")
if __name__ == '__main__':
unittest.main()