Update lexer tests

This commit is contained in:
Kai-Philipp Nosper 2022-02-09 00:20:56 +01:00
parent fdef796440
commit 948d41fb45

View File

@ -237,27 +237,47 @@ mod tests {
#[test] #[test]
fn test_lexer() { fn test_lexer() {
let code = "33 +5*2 + 4456467*2334+3 % - / << ^ | & >>"; let code = r#"53+1-567_000 * / % | ~ ! < > & ^ ({[]});= <- >= <=
== != && || << >> loop if else print my_123var "hello \t world\r\n\"\\""#;
let expected = vec![ let expected = vec![
T![i64(33)], T![i64(53)],
T![+], T![+],
T![i64(5)], T![i64(1)],
T![*],
T![i64(2)],
T![+],
T![i64(4456467)],
T![*],
T![i64(2334)],
T![+],
T![i64(3)],
T![%],
T![-], T![-],
T![i64(567_000)],
T![*],
T![/], T![/],
T![<<], T![%],
T![^],
T![|], T![|],
T![~],
T![!],
T![<],
T![>],
T![&], T![&],
T![^],
T!['('],
T!['{'],
T!['['],
T![']'],
T!['}'],
T![')'],
T![;],
T![=],
T![<-],
T![>=],
T![<=],
T![==],
T![!=],
T![&&],
T![||],
T![<<],
T![>>], T![>>],
T![loop],
T![if],
T![else],
T![print],
T![ident("my_123var".to_string())],
T![str("hello \t world\r\n\"\\".to_string())],
]; ];
let actual = lex(code).unwrap(); let actual = lex(code).unwrap();