aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2017-12-29 20:33:04 +0000
committerAleksey Kladov <[email protected]>2017-12-29 20:33:04 +0000
commit171baf4c4863f035384c6c63a5f0ce531b01cf9d (patch)
tree8dd3885e6d02f64e41275c07bf15491477272182 /tests
parent15af7ad36c507b17093ba86c393272819ff4b3cd (diff)
Simple identifier lexer
Diffstat (limited to 'tests')
-rw-r--r--tests/data/lexer/0001_hello.txt2
-rw-r--r--tests/lexer.rs16
2 files changed, 10 insertions, 8 deletions
diff --git a/tests/data/lexer/0001_hello.txt b/tests/data/lexer/0001_hello.txt
index 5bec9be80..e0b6a1f10 100644
--- a/tests/data/lexer/0001_hello.txt
+++ b/tests/data/lexer/0001_hello.txt
@@ -1,3 +1,3 @@
1IDENT 5 1IDENT 5
2WHITESPACE 1 2WHITESPACE 1
3IDENT 5 \ No newline at end of file 3IDENT 5
diff --git a/tests/lexer.rs b/tests/lexer.rs
index a27e7c395..a3c8916b1 100644
--- a/tests/lexer.rs
+++ b/tests/lexer.rs
@@ -41,13 +41,15 @@ fn lexer_test_case(path: &Path) {
41 dump_tokens(&tokens) 41 dump_tokens(&tokens)
42 }; 42 };
43 let expected = file::get_text(&path.with_extension("txt")).unwrap(); 43 let expected = file::get_text(&path.with_extension("txt")).unwrap();
44 44 let expected = expected.as_str();
45 assert_diff!( 45 let actual = actual.as_str();
46 expected.as_str(), 46 if expected == actual {
47 actual.as_str(), 47 return
48 "\n", 48 }
49 0 49 if expected.trim() == actual.trim() {
50 ) 50 panic!("Whitespace difference!")
51 }
52 assert_diff!(expected, actual, "\n", 0)
51} 53}
52 54
53fn tokenize(text: &str) -> Vec<Token> { 55fn tokenize(text: &str) -> Vec<Token> {