[lexer] Lex bools!

Extend the lexer to support Scheme bools like this: #t, #f, #true, #false.
Add some positive tests for this too.
This commit is contained in:
Eryn Wells 2018-08-26 13:40:27 -07:00
parent b0b4699476
commit a23b917785
6 changed files with 144 additions and 2 deletions

View file

@ -31,3 +31,35 @@ fn lexer_finds_id() {
assert_eq!(lex.next(), Some(Ok(expected_lex)));
assert_eq!(lex.next(), None);
}
#[test]
fn bool_short_true() {
let expected_lex = Lex::new(Token::Bool(true), "#t", 0, 0);
let mut lex = Lexer::new("#t".chars());
assert_eq!(lex.next(), Some(Ok(expected_lex)));
assert_eq!(lex.next(), None);
}
#[test]
fn bool_short_false() {
let expected_lex = Lex::new(Token::Bool(false), "#f", 0, 0);
let mut lex = Lexer::new("#f".chars());
assert_eq!(lex.next(), Some(Ok(expected_lex)));
assert_eq!(lex.next(), None);
}
#[test]
fn bool_long_true() {
let expected_lex = Lex::new(Token::Bool(true), "#true", 0, 0);
let mut lex = Lexer::new("#true".chars());
assert_eq!(lex.next(), Some(Ok(expected_lex)));
assert_eq!(lex.next(), None);
}
#[test]
fn bool_long_false() {
let expected_lex = Lex::new(Token::Bool(false), "#false", 0, 0);
let mut lex = Lexer::new("#false".chars());
assert_eq!(lex.next(), Some(Ok(expected_lex)));
assert_eq!(lex.next(), None);
}