def test_parse_method(self): tokens = lex("print 1 + 1;") parser = Parser(tokens) ast = parser.parse() expected_ast = AST( [PrintStatement(BinOpexpr("+", Integer(1), Integer(1)))]) self.assertEqual(ast, expected_ast)
def test_parse_method(self): tokens = lex("print 1 + 1;") parser = Parser(tokens) ast = parser.parse() expected_ast = AST([PrintStatement( BinOpexpr("+", Integer(1), Integer(1) ) ) ]) self.assertEqual(ast, expected_ast)
def test_parse_statements_method(self): tokens = lex("print 1;") parser = Parser(tokens) parser.parse() expected_ast = AST([PrintStatement(Integer(1))]) self.assertEqual(parser.ast, expected_ast)