コード例 #1
0
    def test_GIVEN_variable_does_not_exist_WHEN_declaring_variable_THEN_no_parse_error(
            self):
        tokens = [
            Token(TokenTypes.Name, "A"),
            Token(TokenTypes.Comma),
            Token(TokenTypes.Noun, 1),
            Token(TokenTypes.EndLine, 1),
            Token(TokenTypes.Eof, 1),
        ]

        parser = Parser(t for t in tokens)

        parser.var_assignment()
コード例 #2
0
    def test_GIVEN_variable_already_exists_WHEN_declaring_variable_THEN_parse_error(
            self):
        tokens = [
            Token(TokenTypes.Name, "A"),
            Token(TokenTypes.Comma),
            Token(TokenTypes.Noun, 1),
            Token(TokenTypes.EndLine, 1),
            Token(TokenTypes.Eof, 1),
        ]

        parser = Parser(t for t in tokens)

        parser.vars_table = ["A"]

        with self.assertRaises(SPLSyntaxError):
            parser.var_assignment()