Python3 ready. Py2.7 and Py3 working. Drop PyCObject for all.
Pre Py2.7 support should be possible by including "capsulethunk.h". (See llvm/wrap.h)
This commit is contained in:
parent
0ca676eb8c
commit
9aadd489c3
14 changed files with 163 additions and 1142 deletions
20
test/asm.py
20
test/asm.py
|
|
@ -25,5 +25,25 @@ class TestAsm(unittest.TestCase):
|
|||
|
||||
self.assertEqual(str(m2).strip(), asm.strip())
|
||||
|
||||
|
||||
def test_bitcode(self):
|
||||
# create a module
|
||||
m = Module.new('module1')
|
||||
m.add_global_variable(Type.int(), 'i')
|
||||
|
||||
# write it's assembly representation to a file
|
||||
asm = str(m)
|
||||
|
||||
with open("/tmp/testasm.bc", "wb") as fout:
|
||||
m.to_bitcode(fout)
|
||||
|
||||
# read it back into a module
|
||||
with open("/tmp/testasm.bc", "rb") as fin:
|
||||
m2 = Module.from_bitcode(fin)
|
||||
# The default `m.id` is '<string>'.
|
||||
m2.id = m.id # Copy the name from `m`
|
||||
|
||||
self.assertEqual(str(m2).strip(), asm.strip())
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class TestConstants(unittest.TestCase):
|
|||
|
||||
# check result
|
||||
for result, golden in zip(results, values):
|
||||
self.assertEqual(result, golden)
|
||||
self.assertEqual(result.decode(), golden)
|
||||
|
||||
def test_const_struct(self):
|
||||
from random import randint, random
|
||||
|
|
@ -201,7 +201,7 @@ class TestConstants(unittest.TestCase):
|
|||
(0, 0., 0.),
|
||||
(-1, -1., -1.),
|
||||
(1, 1., 1.),
|
||||
] + [(randint(0, 0xffffffff), random(), random()) for _ in xrange(100)]
|
||||
] + [(randint(0, 0xffffffff), random(), random()) for _ in range(100)]
|
||||
|
||||
struct_type = Type.struct([Type.int(), Type.float(), Type.double()])
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ class TestConstants(unittest.TestCase):
|
|||
(0, 0, 0, 0),
|
||||
(1, 1, 1, 1),
|
||||
(-1, -1, -1, -1),
|
||||
] + [ (randgen(), randgen(), randgen(), randgen()) for _ in xrange(100) ]
|
||||
] + [ (randgen(), randgen(), randgen(), randgen()) for _ in range(100) ]
|
||||
|
||||
def map_constant(packed_values):
|
||||
consts = [ Constant.int(Type.int(), i) for i in packed_values ]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ except ImportError:
|
|||
import unittest
|
||||
|
||||
def make_module():
|
||||
test_module = u"""
|
||||
test_module = """
|
||||
define i32 @sum(i32, i32) {
|
||||
entry:
|
||||
%2 = add i32 %0, %1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue