Test lexing quotes
This commit is contained in:
parent
b1ef5fdf3e
commit
94579233bf
2 changed files with 19 additions and 7 deletions
|
@ -44,7 +44,7 @@ impl Lexable for char {
|
|||
}
|
||||
|
||||
fn is_quote(&self) -> bool {
|
||||
*self == '''
|
||||
*self == '\''
|
||||
}
|
||||
|
||||
fn is_string_quote(&self) -> bool {
|
||||
|
|
|
@ -498,12 +498,6 @@ mod tests {
|
|||
check_single_token(s, Token::Comment(String::from(s)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_strings() {
|
||||
check_single_token("\"\"", Token::String(String::from("\"\"")));
|
||||
check_single_token("\"abc\"", Token::String(String::from("\"abc\"")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_escaped_characters_in_strings() {
|
||||
check_single_token("\"\\\\\"", Token::String(String::from("\"\\\\\"")));
|
||||
|
@ -552,6 +546,17 @@ mod tests {
|
|||
check_single_token("#h4A65", Token::Number(Number::from_int(0x4A65)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_quote() {
|
||||
check_single_token("'", Token::Quote);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_strings() {
|
||||
check_single_token("\"\"", Token::String(String::from("\"\"")));
|
||||
check_single_token("\"abc\"", Token::String(String::from("\"abc\"")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lexes_simple_expression() {
|
||||
let mut lexer = Lexer::new("(+ 3.4 6.8)");
|
||||
|
@ -562,6 +567,13 @@ mod tests {
|
|||
assert_next_token(&mut lexer, &Token::RightParen(String::from(")")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lexes_quoted_identifier() {
|
||||
let mut lexer = Lexer::new("'abc");
|
||||
assert_next_token(&mut lexer, &Token::Quote);
|
||||
assert_next_token(&mut lexer, &Token::Identifier(String::from("abc")));
|
||||
}
|
||||
|
||||
fn check_single_token(input: &str, expected: Token) {
|
||||
let mut lexer = Lexer::new(input);
|
||||
assert_next_token(&mut lexer, &expected);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue