DDJFKNCB5UBOLFROSXHSL4BZFNQ54Z754DAYET4VNBVI27SKCQ2AC
fn lexer_test_without_whitespace<S, I>(source: S, expected: I)
where
S: AsRef<str>,
I: IntoIterator<Item = (Token, std::ops::Range<usize>, &'static str)>,
{
let source = source.as_ref();
let lexer = Token::lexer(source);
for ((tok, span), (lexed, tspan, tslice)) in lexer
.spanned()
.filter(|(tok, _)| tok.is_err() || tok.as_ref().is_ok_and(|v| v != &Token::Whitespace))
.zip(expected.into_iter())
{
let slice = &source[span.clone()];
check!(tok == Ok(lexed));
check!(span == tspan);
check!(slice == tslice);
}
}
fn lex_booleans() {
let source = r"#t #f #true #false";
let data = [
(Token::Boolean(true), (0..2), "#t"),
(Token::Boolean(false), (3..5), "#f"),
(Token::Boolean(true), (6..11), "#true"),
(Token::Boolean(false), (12..18), "#false"),
];
lexer_test_without_whitespace(source, data)
}
#[test]
let lexer = Token::lexer(source);
for ((tok, span), (lexed, tspan, tslice)) in lexer
.spanned()
.filter(|(tok, _)| tok.is_err() || tok.as_ref().is_ok_and(|v| v != &Token::Whitespace))
.zip(data.into_iter())
{
let slice = &source[span.clone()];
check!(tok == Ok(lexed));
check!(span == tspan);
check!(slice == tslice);
}
lexer_test_without_whitespace(source, data)