diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2015-01-05 07:09:20 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2015-01-05 12:59:40 +0100 |
commit | a9e311030533ac6c175e2289e8928e4aae98b6c3 (patch) | |
tree | 61824b7a755d6e1ed942192d0cf7ec99c2be0f17 /test | |
parent | e48572bca289eba580b96ca6273c0a3fb4e7d47f (diff) | |
download | pygn-a9e311030533ac6c175e2289e8928e4aae98b6c3.tar.gz |
Correctly generating abstract tree (as a list) of all tokens.
Diffstat (limited to 'test')
-rwxr-xr-x | test/test_wlp.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/test/test_wlp.py b/test/test_wlp.py index db6085f..9825e44 100755 --- a/test/test_wlp.py +++ b/test/test_wlp.py @@ -53,11 +53,25 @@ class TestWLP(unittest.TestCase): self.assertEqual(tokens, expected_stream) def test_wlp_parser(self): + expected_tree = [ + [[Token('OWNER', '<kame@innocent.com>'), + [[Token('VAR', 'From:'), + Token('VAL', "'ME'"), + [Token('VAR', 'Sender:'), Token('VAL', '"Cosimo"')], + [Token('VAR', 'Reply-to'), Token('VAL', '"me"')]]]], + [[Token('OWNER', '<alfarano@students.cs.unibo.it>'), + [[Token('VAR', 'From:'), + Token('VAL', "'Cosimo Alfarano'"), + [Token('VAR', 'X-Firstname:'), Token('VAL', "'Cosimo'")]]]]]], + [[Token('OWNER', '<kame@innocent.com>'), + [[Token('VAR', 'From:'), + Token('VAL', "'kame@inwind.it'"), + [Token('VAR', 'Reply-to:'), Token('VAL', '"KA"')], + [Token('VAR', 'Sender:'), Token('VAL', '"Kalfa"')]]]]] + ] lex_stream = wlp_lex.lexer.lex(self.test_input) tree = wlp_yacc.parser.parse(lex_stream) - logging.debug('tree = %s', tree) - logging.debug('tree = dir %s', dir(tree)) - self.assertEqual(tree, []) + self.assertEqual(tree, expected_tree) def test_wlp_C_parser(self): wlp.setfilebyname('examples/whitelist.example') |