From b731b0323aeb18b1f4f29bc4c601f67142a38899 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 27 Dec 2016 10:38:57 -0700 Subject: [PATCH] Update test names: finds for single tokens, lexes for expressions --- src/lexer/mod.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index 3c585ee..5f9e0e6 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -385,14 +385,14 @@ mod tests { use super::token::*; #[test] - fn lexer_finds_parens() { + fn finds_parens() { check_single_token("(", Token::LeftParen(String::from("("))); check_single_token(")", Token::RightParen(String::from(")"))); check_single_token("#(", Token::LeftVectorParen); } #[test] - fn lexer_finds_dots() { + fn finds_dots() { check_single_token(".", Token::Dot); let mut lexer = Lexer::new("abc . abc"); @@ -402,26 +402,28 @@ mod tests { } #[test] - fn lexer_finds_identifiers() { - check_single_token("abc", Token::Identifier(String::from("abc"))); - check_single_token("+", Token::Identifier(String::from("+"))); - check_single_token("-", Token::Identifier(String::from("-"))); + fn finds_identifiers() { + let tok = |s: &str| { check_single_token(s, Token::Identifier(String::from(s))); }; + tok("abc"); + tok("number?"); + tok("+"); + tok("-"); } #[test] - fn lexer_finds_booleans() { + fn finds_booleans() { check_single_token("#t", Token::Boolean(true)); check_single_token("#f", Token::Boolean(false)); } #[test] - fn lexer_finds_comments() { + fn finds_comments() { let s = "; a comment"; check_single_token(s, Token::Comment(String::from(s))); } #[test] - fn lexer_finds_strings() { + fn finds_strings() { check_single_token("\"\"", Token::String(String::from("\"\""))); check_single_token("\"abc\"", Token::String(String::from("\"abc\""))); }