diff options
author | Aleksey Kladov <[email protected]> | 2017-12-29 20:33:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2017-12-29 20:33:04 +0000 |
commit | 171baf4c4863f035384c6c63a5f0ce531b01cf9d (patch) | |
tree | 8dd3885e6d02f64e41275c07bf15491477272182 /tests | |
parent | 15af7ad36c507b17093ba86c393272819ff4b3cd (diff) |
Simple identifier lexer
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/lexer/0001_hello.txt | 2 | ||||
-rw-r--r-- | tests/lexer.rs | 16 |
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 @@ | |||
1 | IDENT 5 | 1 | IDENT 5 |
2 | WHITESPACE 1 | 2 | WHITESPACE 1 |
3 | IDENT 5 \ No newline at end of file | 3 | IDENT 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 | ||
53 | fn tokenize(text: &str) -> Vec<Token> { | 55 | fn tokenize(text: &str) -> Vec<Token> { |