llvmpy/test/constexpr.py
Siu Kwan Lam 5d14461c84 Fix ConstantExpr opcode to use C++ enum values.
Note: C++ opcode is different from C opcode values.
Add ConstantExpr opcode name.
Add test for these.
2012-09-01 20:53:33 -07:00

17 lines
629 B
Python

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()