Ejemplo n.º 1
0
 def test_LexerCore_init(self):
     lc = lexer2.LexerCore("I am a source string", "I am an error constructor")
     assert lc.src == "I am a source string"
     assert lc.syntax_error_ctor == "I am an error constructor"
Ejemplo n.º 2
0
 def test_badlexing(self, input, goal):
     lex = lexer2.LexerCore(input, SyntaxError)
     rv = lex.token(0, getattr(lex, goal))
     assert rv is None
Ejemplo n.º 3
0
 def test_goodlexing(self, input_src, startpos, goal, expected):
     lex = lexer2.LexerCore(input_src, SyntaxError)
     rv = lex.token(startpos, getattr(lex, goal))
     assert rv == expected
Ejemplo n.º 4
0
 def test_string_value_errs(self, input):
     lc = lexer2.LexerCore("", SyntaxError)
     with pytest.raises(SyntaxError):
         lc._string_value(input)
Ejemplo n.º 5
0
 def test_string_value(self, input, expected):
     lc = lexer2.LexerCore("", SyntaxError)
     rv = lc._string_value(input)
     assert rv == expected
Ejemplo n.º 6
0
def run_test(src, expected_type, parse_fcn, *parse_args):
    lex = lexer2.LexerCore(src, SyntaxError)
    rv = parse_fcn(parse2.Parse2Context(src), lex, 0, False, *parse_args)
    assert isinstance(rv, expected_type)