wasm-lang/tests/lexer.rs

45 lines
1.1 KiB
Rust
Raw Permalink Normal View History

2023-10-04 22:10:53 +00:00
use lang::{
lexer::{Lexer, Symbol, Token, TokenContent},
Error,
};
2023-10-04 02:01:06 +00:00
#[test]
fn test_foo() {
let tokens: Result<Vec<_>, Error> = Lexer::new("1 * 5 / 3").collect();
let tokens = tokens.expect("should parse");
2023-10-04 22:10:53 +00:00
assert_eq!(
tokens,
vec![
Token {
span: (0, 1),
token: TokenContent::Number {
radix: 10,
text: "1".into()
},
},
Token {
span: (1, 1),
token: TokenContent::Symbol(Symbol::Star),
},
Token {
span: (2, 1),
token: TokenContent::Number {
radix: 10,
text: "5".into()
},
},
Token {
span: (3, 1),
token: TokenContent::Symbol(Symbol::Slash),
},
Token {
span: (4, 1),
token: TokenContent::Number {
radix: 10,
text: "3".into()
},
},
]
)
2023-10-04 02:01:06 +00:00
}