diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lexer.rs | 15 | ||||
-rw-r--r-- | tests/parser.rs | 15 |
2 files changed, 12 insertions, 18 deletions
diff --git a/tests/lexer.rs b/tests/lexer.rs index 20840f456..397ebafdd 100644 --- a/tests/lexer.rs +++ b/tests/lexer.rs | |||
@@ -4,18 +4,15 @@ extern crate testutils; | |||
4 | 4 | ||
5 | use std::fmt::Write; | 5 | use std::fmt::Write; |
6 | 6 | ||
7 | use libsyntax2::{Token, tokenize}; | 7 | use libsyntax2::{tokenize, Token}; |
8 | use testutils::dir_tests; | 8 | use testutils::dir_tests; |
9 | 9 | ||
10 | #[test] | 10 | #[test] |
11 | fn lexer_tests() { | 11 | fn lexer_tests() { |
12 | dir_tests( | 12 | dir_tests(&["lexer"], |text| { |
13 | &["lexer"], | 13 | let tokens = tokenize(text); |
14 | |text| { | 14 | dump_tokens(&tokens, text) |
15 | let tokens = tokenize(text); | 15 | }) |
16 | dump_tokens(&tokens, text) | ||
17 | } | ||
18 | ) | ||
19 | } | 16 | } |
20 | 17 | ||
21 | fn dump_tokens(tokens: &[Token], text: &str) -> String { | 18 | fn dump_tokens(tokens: &[Token], text: &str) -> String { |
@@ -29,4 +26,4 @@ fn dump_tokens(tokens: &[Token], text: &str) -> String { | |||
29 | write!(acc, "{:?} {} {:?}\n", token.kind, token.len, token_text).unwrap() | 26 | write!(acc, "{:?} {} {:?}\n", token.kind, token.len, token_text).unwrap() |
30 | } | 27 | } |
31 | acc | 28 | acc |
32 | } \ No newline at end of file | 29 | } |
diff --git a/tests/parser.rs b/tests/parser.rs index 370b02c74..37c9021ef 100644 --- a/tests/parser.rs +++ b/tests/parser.rs | |||
@@ -2,18 +2,15 @@ extern crate file; | |||
2 | extern crate libsyntax2; | 2 | extern crate libsyntax2; |
3 | extern crate testutils; | 3 | extern crate testutils; |
4 | 4 | ||
5 | use libsyntax2::{tokenize, parse}; | 5 | use libsyntax2::{parse, tokenize}; |
6 | use libsyntax2::utils::dump_tree; | 6 | use libsyntax2::utils::dump_tree; |
7 | use testutils::dir_tests; | 7 | use testutils::dir_tests; |
8 | 8 | ||
9 | #[test] | 9 | #[test] |
10 | fn parser_tests() { | 10 | fn parser_tests() { |
11 | dir_tests( | 11 | dir_tests(&["parser/ok", "parser/err"], |text| { |
12 | &["parser/ok", "parser/err"], | 12 | let tokens = tokenize(text); |
13 | |text| { | 13 | let file = parse(text.to_string(), &tokens); |
14 | let tokens = tokenize(text); | 14 | dump_tree(&file) |
15 | let file = parse(text.to_string(), &tokens); | 15 | }) |
16 | dump_tree(&file) | ||
17 | } | ||
18 | ) | ||
19 | } | 16 | } |