From a9e311030533ac6c175e2289e8928e4aae98b6c3 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 5 Jan 2015 07:09:20 +0100 Subject: Correctly generating abstract tree (as a list) of all tokens. --- test/test_wlp.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'test') 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', ''), + [[Token('VAR', 'From:'), + Token('VAL', "'ME'"), + [Token('VAR', 'Sender:'), Token('VAL', '"Cosimo"')], + [Token('VAR', 'Reply-to'), Token('VAL', '"me"')]]]], + [[Token('OWNER', ''), + [[Token('VAR', 'From:'), + Token('VAL', "'Cosimo Alfarano'"), + [Token('VAR', 'X-Firstname:'), Token('VAL', "'Cosimo'")]]]]]], + [[Token('OWNER', ''), + [[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') -- cgit