add constant expression test
This commit is contained in:
parent
9a51ead50e
commit
81d6da3ae5
2 changed files with 16 additions and 17 deletions
|
|
@ -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):
|
class TestOperands(unittest.TestCase):
|
||||||
# implement a test function
|
# implement a test function
|
||||||
test_module = """
|
test_module = """
|
||||||
|
|
|
||||||
|
|
@ -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()
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue