fn lex_decimal() {
let source = r"0.0 -0.0e0 -.0 .0e0 0e-1";
let data = [
((0.0, 0), (0..3), "0.0"),
((-0.0, 0), (4..10), "-0.0e0"),
((-0.0, 0), (11..14), "-.0"),
((0.0, 0), (15..19), ".0e0"),
((0.0, -1), (20..24), "0e-1"),
];
let lexer = Token::lexer(source);
for ((_, (tok, span)), (parsed, tspan, tslice)) in lexer
.spanned()
.enumerate()
// Skip all odd-indexed tokens (it's whitespace)
.filter(|(idx, _)| idx % 2 == 0)
.zip(data.into_iter())
{
let slice = &source[span.clone()];
assert!(tok == Ok(Token::Decimal(parsed)));
assert!(span == tspan);
assert!(slice == tslice);
}
}
#[test]