def test_numbers(self): takens=[Token(TokenType.NUMBER, 51.2)] node= Parser(tokens).parse() self.assertEqual(node, NumberNode(51.2))
self.assertEqual(node, AddNode(NumberNode(27),NumberNode(14))) takens= [ Token(TokenType.NUMBER, 27), Token(TokenType.MINUS), Token(TokenType.NUMBER, 14), ] node = Parser(tokens).parse() self.assertEqual(node, SubtractNode(NumberNode(27),NumberNode(14))) takens= [ Token(TokenType.NUMBER, 27), Token(TokenType.MULTIPLY), Token(TokenType.NUMBER, 14), ] node = Parser(tokens).parse() self.assertEqual(node, MultiplyNode(NumberNode(27),NumberNode(14))) takens= [ Token(TokenType.NUMBER, 27), Token(TokenType.DIVIDE), Token(TokenType.NUMBER, 14), ] node = Parser(tokens).parse() self.assertEqual(node, divideNode(NumberNode(27),NumberNode(14))) def test_full_expression(self): tokens =[ Token(TokenType.NUMBER, 27), Token(TokenType.PLUS), Token(TokenType.LPAREN),