diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-09-11 00:52:47 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-09-11 00:52:47 +0000 |
commit | 7dfa4bc4716aaa34cc7c6226fd00675899263e9d (patch) | |
tree | 749dbbbfde6a37cdf9754f5234dd8482be42199e /bindings/python/llvm/tests | |
parent | 7eb8b0fd84474f6a77ffa6211c0c753ed3142277 (diff) | |
download | external_llvm-7dfa4bc4716aaa34cc7c6226fd00675899263e9d.zip external_llvm-7dfa4bc4716aaa34cc7c6226fd00675899263e9d.tar.gz external_llvm-7dfa4bc4716aaa34cc7c6226fd00675899263e9d.tar.bz2 |
[python-bindings] Added support for getting a module's functions, iterating f/b over said functions, dumping/print name of functions.
Tests are included as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/llvm/tests')
-rw-r--r-- | bindings/python/llvm/tests/test_core.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bindings/python/llvm/tests/test_core.py b/bindings/python/llvm/tests/test_core.py index 07a574e..a1f79a4 100644 --- a/bindings/python/llvm/tests/test_core.py +++ b/bindings/python/llvm/tests/test_core.py @@ -4,6 +4,7 @@ from ..core import MemoryBuffer from ..core import PassRegistry from ..core import Context from ..core import Module +from ..bit_reader import parse_bitcode class TestCore(TestBase): def test_opcode(self): @@ -61,3 +62,19 @@ class TestCore(TestBase): m.target = target m.print_module_to_file("test2.ll") + def test_module_function_iteration(self): + m = parse_bitcode(MemoryBuffer(filename=self.get_test_bc())) + i = 0 + functions = ["f", "f2", "f3", "f4", "f5", "f6", "g1", "g2", "h1", "h2", + "h3"] + # Forward + for f in m: + self.assertEqual(f.name, functions[i]) + f.dump() + i += 1 + # Backwards + for f in reversed(m): + i -= 1 + self.assertEqual(f.name, functions[i]) + f.dump() + |