def test_attribute_reference(self): code = ".speed \0" self.manage_source(code) self.parser.consume_token() self.assertEqual( True, self.parser.try_parse_attribute_reference(env.Identifier("a"), False))
def try_parse_identifier(self): if self.current_token.token_type == tokens.TokenType.t_identifier: self.class_stack.append(env.Identifier(self.current_token.value)) self.consume_token() return True return False
def test_method_call(self): code = ".run(a, b, c, d)\0" self.manage_source(code) self.parser.consume_token() self.assertEqual( True, self.parser.try_parse_method_call(env.Identifier("a")))
def test_function_call(self): code = "(a, b, c, d);\0" self.manage_source(code) self.parser.consume_token() self.assertEqual( True, self.parser.try_parse_function_call(env.Identifier("a")))
def test_attribute(self): code = "{get; set} = \'abcde\'; \0" self.manage_source(code) self.parser.consume_token() self.assertEqual(True, self.parser.try_parse_attribute(env.Identifier("a")))
def test_object(self): code = " extends Vehicle { a= None; b = 10; } \0" self.manage_source(code) self.parser.consume_token() self.assertEqual(True, self.parser.try_parse_object(env.Identifier("a")))
def test_assignment(self): code = "= 5 + 3 * 2 + ( 7 * 9 ) \0" self.manage_source(code) self.parser.consume_token() self.assertEqual(True, self.parser.try_parse_assignment(env.Identifier("a")))
def test_function(self): code = "(){ a = 5; out<<a; } \0" self.manage_source(code) self.parser.consume_token() self.assertEqual( True, self.parser.try_parse_function(env.Identifier("main")))