Permalink
Please sign in to comment.
Browse files
Correctly handle the repeated string type in the ASDL pretty printer.
There was a case missing, so there were two unnecessary repr() calls. Also: - Research on serializing the parsed ASDL schema. We need this for metaprogramming.
- Loading branch information...
Showing
with
76 additions
and 5 deletions.
- +3 −0 asdl/arith.asdl
- +18 −1 asdl/asdl_demo.py
- +15 −4 asdl/format.py
- +36 −0 asdl/format_test.py
- +4 −0 asdl/run.sh
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/python -S | ||
| """ | ||
| format_test.py: Tests for format.py | ||
| """ | ||
| import cStringIO | ||
| import sys | ||
| import unittest | ||
| from asdl import format as fmt | ||
| from asdl import asdl_ | ||
| from asdl import arith_ast # module under test | ||
| class FormatTest(unittest.TestCase): | ||
| def testRepeatedString(self): | ||
| node = arith_ast.assign('declare', ['-r', '-x']) | ||
| f = cStringIO.StringIO() | ||
| ast_f = fmt.TextOutput(f) | ||
| tree = fmt.MakeTree(node) | ||
| #print(tree) | ||
| fmt.PrintTree(tree, ast_f) | ||
| pretty_str = f.getvalue() | ||
| print(pretty_str) | ||
| self.assertEqual('(assign name:declare flags:[-r -x])', pretty_str) | ||
| if __name__ == '__main__': | ||
| unittest.main() |
0 comments on commit
9d9f077