mirror of https://github.com/boa-dev/boa.git
Jason Williams
6 years ago
5 changed files with 40 additions and 3 deletions
@ -0,0 +1,23 @@
|
||||
extern crate js; |
||||
use js::syntax::ast::keyword::Keyword; |
||||
use js::syntax::ast::punc::Punctuator; |
||||
use js::syntax::ast::token::TokenData; |
||||
use js::syntax::lexer::Lexer; |
||||
|
||||
#[test] |
||||
/// Check basic variable definition tokens
|
||||
fn check_variable_definition_tokens() { |
||||
let s = &String::from("let a = 'hello';"); |
||||
let mut lexer = Lexer::new(s); |
||||
lexer.lex().expect("finished"); |
||||
assert_eq!(lexer.tokens[0].data, TokenData::Keyword(Keyword::Let)); |
||||
assert_eq!(lexer.tokens[1].data, TokenData::Identifier("a".to_string())); |
||||
assert_eq!( |
||||
lexer.tokens[2].data, |
||||
TokenData::Punctuator(Punctuator::Assign) |
||||
); |
||||
assert_eq!( |
||||
lexer.tokens[3].data, |
||||
TokenData::StringLiteral("hello".to_string()) |
||||
); |
||||
} |
Loading…
Reference in new issue