macroexpander_test.py (9f22d7c2) | macroexpander_test.py (7d9fa7c3) |
---|---|
1#!/usr/bin/env python 2# ************************************************************* 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the --- 17 unchanged lines hidden (view full) --- 26class TestCase: 27 28 @staticmethod 29 def run (tokens, defines): 30 mcExpander = srcparser.MacroExpander(tokens, defines) 31 mcExpander.debug = True 32 mcExpander.expand() 33 tokens = mcExpander.getTokens() | 1#!/usr/bin/env python 2# ************************************************************* 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the --- 17 unchanged lines hidden (view full) --- 26class TestCase: 27 28 @staticmethod 29 def run (tokens, defines): 30 mcExpander = srcparser.MacroExpander(tokens, defines) 31 mcExpander.debug = True 32 mcExpander.expand() 33 tokens = mcExpander.getTokens() |
34 print tokens | 34 print(tokens) |
35 36 @staticmethod 37 def simpleNoArgs (): 38 tokens = ['FUNC_FOO', '(', 'left', ',', 'right', ')'] 39 defines = {} 40 macro = globals.Macro('FUNC_FOO') 41 macro.tokens = ['Here', 'comes', 'X', 'and', 'Y'] 42 defines['FUNC_FOO'] = macro --- 31 unchanged lines hidden (view full) --- 74 macro.vars['Y'] = 1 75 defines['FUNC_FOO'] = macro 76 macro = globals.Macro('FUNC_BAA') 77 macro.tokens = ['FUNC_FOO'] 78 defines['FUNC_BAA'] = macro 79 TestCase.run(tokens, defines) 80 81def main (): | 35 36 @staticmethod 37 def simpleNoArgs (): 38 tokens = ['FUNC_FOO', '(', 'left', ',', 'right', ')'] 39 defines = {} 40 macro = globals.Macro('FUNC_FOO') 41 macro.tokens = ['Here', 'comes', 'X', 'and', 'Y'] 42 defines['FUNC_FOO'] = macro --- 31 unchanged lines hidden (view full) --- 74 macro.vars['Y'] = 1 75 defines['FUNC_FOO'] = macro 76 macro = globals.Macro('FUNC_BAA') 77 macro.tokens = ['FUNC_FOO'] 78 defines['FUNC_BAA'] = macro 79 TestCase.run(tokens, defines) 80 81def main (): |
82 print "simple expansion with no arguments" | 82 print("simple expansion with no arguments") |
83 TestCase.simpleNoArgs() | 83 TestCase.simpleNoArgs() |
84 print "simple argument expansion" | 84 print("simple argument expansion") |
85 TestCase.simpleArgs() | 85 TestCase.simpleArgs() |
86 print "multi-token argument expansion" | 86 print("multi-token argument expansion") |
87 TestCase.multiTokenArgs() | 87 TestCase.multiTokenArgs() |
88 print "nested argument expansion" | 88 print("nested argument expansion") |
89 TestCase.nestedTokenArgs() 90 91if __name__ == '__main__': 92 main() | 89 TestCase.nestedTokenArgs() 90 91if __name__ == '__main__': 92 main() |