aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lexer.rs15
-rw-r--r--tests/parser.rs15
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
5use std::fmt::Write; 5use std::fmt::Write;
6 6
7use libsyntax2::{Token, tokenize}; 7use libsyntax2::{tokenize, Token};
8use testutils::dir_tests; 8use testutils::dir_tests;
9 9
10#[test] 10#[test]
11fn lexer_tests() { 11fn 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
21fn dump_tokens(tokens: &[Token], text: &str) -> String { 18fn 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;
2extern crate libsyntax2; 2extern crate libsyntax2;
3extern crate testutils; 3extern crate testutils;
4 4
5use libsyntax2::{tokenize, parse}; 5use libsyntax2::{parse, tokenize};
6use libsyntax2::utils::dump_tree; 6use libsyntax2::utils::dump_tree;
7use testutils::dir_tests; 7use testutils::dir_tests;
8 8
9#[test] 9#[test]
10fn parser_tests() { 10fn 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}