wasm-lang/tests/lexer.rs
2023-10-04 15:10:53 -07:00

44 lines
1.1 KiB
Rust

use lang::{
lexer::{Lexer, Symbol, Token, TokenContent},
Error,
};
#[test]
fn test_foo() {
let tokens: Result<Vec<_>, Error> = Lexer::new("1 * 5 / 3").collect();
let tokens = tokens.expect("should parse");
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()
},
},
]
)
}