|
@@ -183,6 +183,14 @@ mod tests {
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
+ #[test]
|
|
|
+ #[should_panic(expected = "InvalidInstruction { line: 1, column: 1, instruction: \"print\" }")]
|
|
|
+ fn invalid_instruction() {
|
|
|
+ Lexer::new()
|
|
|
+ .tokenize("print".chars())
|
|
|
+ .unwrap();
|
|
|
+ }
|
|
|
+
|
|
|
#[test]
|
|
|
fn decimals() -> Result<(), LexerError> {
|
|
|
for n in [0, 23, 42, 1337, 500000] {
|
|
@@ -207,4 +215,19 @@ mod tests {
|
|
|
.tokenize((u64::MAX.to_string() + "0").chars())
|
|
|
.unwrap();
|
|
|
}
|
|
|
+
|
|
|
+ #[test]
|
|
|
+ fn comma() -> Result<(), LexerError> {
|
|
|
+ let tokens = Lexer::new()
|
|
|
+ .tokenize(",".chars())?;
|
|
|
+ let expected = vec![
|
|
|
+ TokenInfo {
|
|
|
+ token: Token::Comma,
|
|
|
+ line: 1,
|
|
|
+ column: 1,
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ assert_eq!(tokens, expected);
|
|
|
+ Ok(())
|
|
|
+ }
|
|
|
}
|