diff options
Diffstat (limited to 'tests')
15 files changed, 54 insertions, 51 deletions
diff --git a/tests/data/parser/err/0000_struct_field_missing_comma.txt b/tests/data/parser/err/0000_struct_field_missing_comma.txt index 5196fd718..2bb3ee6ec 100644 --- a/tests/data/parser/err/0000_struct_field_missing_comma.txt +++ b/tests/data/parser/err/0000_struct_field_missing_comma.txt | |||
@@ -18,7 +18,7 @@ FILE@[0; 34) | |||
18 | WHITESPACE@[17; 18) | 18 | WHITESPACE@[17; 18) |
19 | IDENT@[18; 21) "u32" | 19 | IDENT@[18; 21) "u32" |
20 | WHITESPACE@[21; 26) | 20 | WHITESPACE@[21; 26) |
21 | err: `expected COMMA` | 21 | err: `expected COMMA` |
22 | NAMED_FIELD@[26; 33) | 22 | NAMED_FIELD@[26; 33) |
23 | NAME@[26; 27) | 23 | NAME@[26; 27) |
24 | IDENT@[26; 27) "b" | 24 | IDENT@[26; 27) "b" |
diff --git a/tests/data/parser/err/0001_item_recovery_in_file.txt b/tests/data/parser/err/0001_item_recovery_in_file.txt index e41ddc009..01bd2abe6 100644 --- a/tests/data/parser/err/0001_item_recovery_in_file.txt +++ b/tests/data/parser/err/0001_item_recovery_in_file.txt | |||
@@ -1,10 +1,10 @@ | |||
1 | FILE@[0; 21) | 1 | FILE@[0; 21) |
2 | err: `expected item` | ||
2 | ERROR@[0; 3) | 3 | ERROR@[0; 3) |
3 | err: `expected item` | ||
4 | IF_KW@[0; 2) | 4 | IF_KW@[0; 2) |
5 | WHITESPACE@[2; 3) | 5 | WHITESPACE@[2; 3) |
6 | err: `expected item` | ||
6 | ERROR@[3; 10) | 7 | ERROR@[3; 10) |
7 | err: `expected item` | ||
8 | MATCH_KW@[3; 8) | 8 | MATCH_KW@[3; 8) |
9 | WHITESPACE@[8; 10) | 9 | WHITESPACE@[8; 10) |
10 | STRUCT_ITEM@[10; 21) | 10 | STRUCT_ITEM@[10; 21) |
diff --git a/tests/data/parser/err/0002_duplicate_shebang.txt b/tests/data/parser/err/0002_duplicate_shebang.txt index e7cf7187d..1a4b37da8 100644 --- a/tests/data/parser/err/0002_duplicate_shebang.txt +++ b/tests/data/parser/err/0002_duplicate_shebang.txt | |||
@@ -1,7 +1,7 @@ | |||
1 | FILE@[0; 42) | 1 | FILE@[0; 42) |
2 | SHEBANG@[0; 20) | 2 | SHEBANG@[0; 20) |
3 | ERROR@[20; 42) | ||
4 | err: `expected item` | 3 | err: `expected item` |
4 | ERROR@[20; 42) | ||
5 | WHITESPACE@[20; 21) | 5 | WHITESPACE@[20; 21) |
6 | SHEBANG@[21; 41) | 6 | SHEBANG@[21; 41) |
7 | WHITESPACE@[41; 42) | 7 | WHITESPACE@[41; 42) |
diff --git a/tests/data/parser/err/0003_C++_semicolon.txt b/tests/data/parser/err/0003_C++_semicolon.txt index affe8fd09..dc3cf6c73 100644 --- a/tests/data/parser/err/0003_C++_semicolon.txt +++ b/tests/data/parser/err/0003_C++_semicolon.txt | |||
@@ -32,7 +32,7 @@ FILE@[0; 40) | |||
32 | COMMA@[36; 37) | 32 | COMMA@[36; 37) |
33 | WHITESPACE@[37; 38) | 33 | WHITESPACE@[37; 38) |
34 | R_CURLY@[38; 39) | 34 | R_CURLY@[38; 39) |
35 | ERROR@[39; 40) | 35 | err: `expected item, found `;` |
36 | err: `expected item, found `;` | ||
37 | consider removing this semicolon` | 36 | consider removing this semicolon` |
37 | ERROR@[39; 40) | ||
38 | SEMI@[39; 40) | 38 | SEMI@[39; 40) |
diff --git a/tests/data/parser/err/0004_use_path_bad_segment.txt b/tests/data/parser/err/0004_use_path_bad_segment.txt index 0a67002ac..d9ff79ebe 100644 --- a/tests/data/parser/err/0004_use_path_bad_segment.txt +++ b/tests/data/parser/err/0004_use_path_bad_segment.txt | |||
@@ -9,13 +9,13 @@ FILE@[0; 12) | |||
9 | WHITESPACE@[3; 4) | 9 | WHITESPACE@[3; 4) |
10 | IDENT@[4; 7) "foo" | 10 | IDENT@[4; 7) "foo" |
11 | COLONCOLON@[7; 9) | 11 | COLONCOLON@[7; 9) |
12 | PATH_SEGMENT@[9; 9) | 12 | err: `expected SEMI` |
13 | err: `expected identifier` | 13 | err: `expected identifier` |
14 | err: `expected SEMI` | 14 | err: `expected item` |
15 | PATH_SEGMENT@[9; 9) | ||
15 | ERROR@[9; 11) | 16 | ERROR@[9; 11) |
16 | err: `expected item` | ||
17 | INT_NUMBER@[9; 11) | 17 | INT_NUMBER@[9; 11) |
18 | ERROR@[11; 12) | 18 | err: `expected item, found `;` |
19 | err: `expected item, found `;` | ||
20 | consider removing this semicolon` | 19 | consider removing this semicolon` |
20 | ERROR@[11; 12) | ||
21 | SEMI@[11; 12) | 21 | SEMI@[11; 12) |
diff --git a/tests/data/parser/err/0005_attribute_recover.txt b/tests/data/parser/err/0005_attribute_recover.txt index 731f5f2f8..74dd38959 100644 --- a/tests/data/parser/err/0005_attribute_recover.txt +++ b/tests/data/parser/err/0005_attribute_recover.txt | |||
@@ -9,12 +9,12 @@ FILE@[0; 54) | |||
9 | META_ITEM@[6; 9) | 9 | META_ITEM@[6; 9) |
10 | IDENT@[6; 9) "foo" | 10 | IDENT@[6; 9) "foo" |
11 | COMMA@[9; 10) | 11 | COMMA@[9; 10) |
12 | ERROR@[10; 12) | ||
13 | err: `expected attribute` | 12 | err: `expected attribute` |
13 | ERROR@[10; 12) | ||
14 | WHITESPACE@[10; 11) | 14 | WHITESPACE@[10; 11) |
15 | PLUS@[11; 12) | 15 | PLUS@[11; 12) |
16 | err: `expected attribute` | ||
16 | ERROR@[12; 14) | 17 | ERROR@[12; 14) |
17 | err: `expected attribute` | ||
18 | COMMA@[12; 13) | 18 | COMMA@[12; 13) |
19 | WHITESPACE@[13; 14) | 19 | WHITESPACE@[13; 14) |
20 | LITERAL@[14; 16) | 20 | LITERAL@[14; 16) |
@@ -43,7 +43,7 @@ FILE@[0; 54) | |||
43 | L_PAREN@[39; 40) | 43 | L_PAREN@[39; 40) |
44 | err: `expected attribute` | 44 | err: `expected attribute` |
45 | WHITESPACE@[40; 41) | 45 | WHITESPACE@[40; 41) |
46 | err: `expected R_BRACK` | 46 | err: `expected R_BRACK` |
47 | FN_KW@[41; 43) | 47 | FN_KW@[41; 43) |
48 | NAME@[43; 47) | 48 | NAME@[43; 47) |
49 | WHITESPACE@[43; 44) | 49 | WHITESPACE@[43; 44) |
diff --git a/tests/data/parser/err/0006_named_field_recovery.txt b/tests/data/parser/err/0006_named_field_recovery.txt index 2dec74866..cb5a9c32c 100644 --- a/tests/data/parser/err/0006_named_field_recovery.txt +++ b/tests/data/parser/err/0006_named_field_recovery.txt | |||
@@ -22,23 +22,26 @@ FILE@[0; 74) | |||
22 | WHITESPACE@[22; 27) | 22 | WHITESPACE@[22; 27) |
23 | PUB_KW@[27; 30) | 23 | PUB_KW@[27; 30) |
24 | WHITESPACE@[30; 31) | 24 | WHITESPACE@[30; 31) |
25 | err: `expected field declaration` | ||
25 | ERROR@[31; 38) | 26 | ERROR@[31; 38) |
26 | err: `expected field declaration` | ||
27 | INT_NUMBER@[31; 33) | 27 | INT_NUMBER@[31; 33) |
28 | WHITESPACE@[33; 38) | 28 | WHITESPACE@[33; 38) |
29 | err: `expected COMMA` | 29 | err: `expected COMMA` |
30 | err: `expected field declaration` | ||
30 | ERROR@[38; 40) | 31 | ERROR@[38; 40) |
31 | err: `expected field declaration` | ||
32 | PLUS@[38; 39) | 32 | PLUS@[38; 39) |
33 | WHITESPACE@[39; 40) | 33 | WHITESPACE@[39; 40) |
34 | err: `expected COMMA` | ||
35 | err: `expected field declaration` | ||
34 | ERROR@[40; 42) | 36 | ERROR@[40; 42) |
35 | err: `expected field declaration` | ||
36 | MINUS@[40; 41) | 37 | MINUS@[40; 41) |
37 | WHITESPACE@[41; 42) | 38 | WHITESPACE@[41; 42) |
39 | err: `expected COMMA` | ||
40 | err: `expected field declaration` | ||
38 | ERROR@[42; 48) | 41 | ERROR@[42; 48) |
39 | err: `expected field declaration` | ||
40 | STAR@[42; 43) | 42 | STAR@[42; 43) |
41 | WHITESPACE@[43; 48) | 43 | WHITESPACE@[43; 48) |
44 | err: `expected COMMA` | ||
42 | NAMED_FIELD@[48; 58) | 45 | NAMED_FIELD@[48; 58) |
43 | VISIBILITY@[48; 52) | 46 | VISIBILITY@[48; 52) |
44 | PUB_KW@[48; 51) | 47 | PUB_KW@[48; 51) |
diff --git a/tests/data/parser/err/0007_stray_curly_in_file.txt b/tests/data/parser/err/0007_stray_curly_in_file.txt index 8a3cb5096..cfc714cc6 100644 --- a/tests/data/parser/err/0007_stray_curly_in_file.txt +++ b/tests/data/parser/err/0007_stray_curly_in_file.txt | |||
@@ -1,6 +1,6 @@ | |||
1 | FILE@[0; 31) | 1 | FILE@[0; 31) |
2 | err: `expected item` | ||
2 | ERROR@[0; 3) | 3 | ERROR@[0; 3) |
3 | err: `expected item` | ||
4 | R_CURLY@[0; 1) | 4 | R_CURLY@[0; 1) |
5 | WHITESPACE@[1; 3) | 5 | WHITESPACE@[1; 3) |
6 | STRUCT_ITEM@[3; 14) | 6 | STRUCT_ITEM@[3; 14) |
@@ -10,8 +10,8 @@ FILE@[0; 31) | |||
10 | IDENT@[10; 11) "S" | 10 | IDENT@[10; 11) "S" |
11 | SEMI@[11; 12) | 11 | SEMI@[11; 12) |
12 | WHITESPACE@[12; 14) | 12 | WHITESPACE@[12; 14) |
13 | err: `expected item` | ||
13 | ERROR@[14; 17) | 14 | ERROR@[14; 17) |
14 | err: `expected item` | ||
15 | R_CURLY@[14; 15) | 15 | R_CURLY@[14; 15) |
16 | WHITESPACE@[15; 17) | 16 | WHITESPACE@[15; 17) |
17 | FN_ITEM@[17; 29) | 17 | FN_ITEM@[17; 29) |
@@ -25,7 +25,7 @@ FILE@[0; 31) | |||
25 | L_CURLY@[25; 26) | 25 | L_CURLY@[25; 26) |
26 | R_CURLY@[26; 27) | 26 | R_CURLY@[26; 27) |
27 | WHITESPACE@[27; 29) | 27 | WHITESPACE@[27; 29) |
28 | err: `expected item` | ||
28 | ERROR@[29; 31) | 29 | ERROR@[29; 31) |
29 | err: `expected item` | ||
30 | R_CURLY@[29; 30) | 30 | R_CURLY@[29; 30) |
31 | WHITESPACE@[30; 31) | 31 | WHITESPACE@[30; 31) |
diff --git a/tests/data/parser/err/0008_item_block_recovery.txt b/tests/data/parser/err/0008_item_block_recovery.txt index 0e2aae7cc..ca332bcf0 100644 --- a/tests/data/parser/err/0008_item_block_recovery.txt +++ b/tests/data/parser/err/0008_item_block_recovery.txt | |||
@@ -12,18 +12,18 @@ FILE@[0; 95) | |||
12 | WHITESPACE@[10; 11) | 12 | WHITESPACE@[10; 11) |
13 | R_CURLY@[11; 12) | 13 | R_CURLY@[11; 12) |
14 | WHITESPACE@[12; 14) | 14 | WHITESPACE@[12; 14) |
15 | err: `expected item` | ||
15 | ERROR@[14; 17) | 16 | ERROR@[14; 17) |
16 | err: `expected item` | ||
17 | IDENT@[14; 17) "bar" | 17 | IDENT@[14; 17) "bar" |
18 | err: `expected item` | ||
18 | ERROR@[17; 18) | 19 | ERROR@[17; 18) |
19 | err: `expected item` | ||
20 | L_PAREN@[17; 18) | 20 | L_PAREN@[17; 18) |
21 | err: `expected item` | ||
21 | ERROR@[18; 20) | 22 | ERROR@[18; 20) |
22 | err: `expected item` | ||
23 | R_PAREN@[18; 19) | 23 | R_PAREN@[18; 19) |
24 | WHITESPACE@[19; 20) | 24 | WHITESPACE@[19; 20) |
25 | err: `expected item` | ||
25 | ERROR@[20; 82) | 26 | ERROR@[20; 82) |
26 | err: `expected item` | ||
27 | L_CURLY@[20; 21) | 27 | L_CURLY@[20; 21) |
28 | WHITESPACE@[21; 26) | 28 | WHITESPACE@[21; 26) |
29 | IF_KW@[26; 28) | 29 | IF_KW@[26; 28) |
diff --git a/tests/data/parser/err/0009_broken_struct_type_parameter.txt b/tests/data/parser/err/0009_broken_struct_type_parameter.txt index 9434a764a..c16c6dffe 100644 --- a/tests/data/parser/err/0009_broken_struct_type_parameter.txt +++ b/tests/data/parser/err/0009_broken_struct_type_parameter.txt | |||
@@ -6,26 +6,26 @@ FILE@[0; 43) | |||
6 | IDENT@[7; 8) "S" | 6 | IDENT@[7; 8) "S" |
7 | TYPE_PARAM_LIST@[8; 12) | 7 | TYPE_PARAM_LIST@[8; 12) |
8 | L_ANGLE@[8; 9) | 8 | L_ANGLE@[8; 9) |
9 | ERROR@[9; 12) | ||
10 | err: `expected type parameter` | 9 | err: `expected type parameter` |
10 | ERROR@[9; 12) | ||
11 | INT_NUMBER@[9; 11) | 11 | INT_NUMBER@[9; 11) |
12 | WHITESPACE@[11; 12) | 12 | WHITESPACE@[11; 12) |
13 | err: `expected COMMA` | 13 | err: `expected COMMA` |
14 | err: `expected R_ANGLE` | 14 | err: `expected R_ANGLE` |
15 | err: `expected `;`, `{`, or `(`` | 15 | err: `expected `;`, `{`, or `(`` |
16 | err: `expected item` | ||
16 | ERROR@[12; 14) | 17 | ERROR@[12; 14) |
17 | err: `expected item` | ||
18 | PLUS@[12; 13) | 18 | PLUS@[12; 13) |
19 | WHITESPACE@[13; 14) | 19 | WHITESPACE@[13; 14) |
20 | err: `expected item` | ||
20 | ERROR@[14; 15) | 21 | ERROR@[14; 15) |
21 | err: `expected item` | ||
22 | INT_NUMBER@[14; 15) | 22 | INT_NUMBER@[14; 15) |
23 | err: `expected item` | ||
23 | ERROR@[15; 17) | 24 | ERROR@[15; 17) |
24 | err: `expected item` | ||
25 | R_ANGLE@[15; 16) | 25 | R_ANGLE@[15; 16) |
26 | WHITESPACE@[16; 17) | 26 | WHITESPACE@[16; 17) |
27 | err: `expected item` | ||
27 | ERROR@[17; 33) | 28 | ERROR@[17; 33) |
28 | err: `expected item` | ||
29 | L_CURLY@[17; 18) | 29 | L_CURLY@[17; 18) |
30 | WHITESPACE@[18; 23) | 30 | WHITESPACE@[18; 23) |
31 | IDENT@[23; 24) "f" | 31 | IDENT@[23; 24) "f" |
diff --git a/tests/data/parser/inline/0006_extern_struct.txt b/tests/data/parser/inline/0006_extern_struct.txt index 93a5b0477..f310e1225 100644 --- a/tests/data/parser/inline/0006_extern_struct.txt +++ b/tests/data/parser/inline/0006_extern_struct.txt | |||
@@ -2,7 +2,7 @@ FILE@[0; 19) | |||
2 | ABI@[0; 7) | 2 | ABI@[0; 7) |
3 | EXTERN_KW@[0; 6) | 3 | EXTERN_KW@[0; 6) |
4 | WHITESPACE@[6; 7) | 4 | WHITESPACE@[6; 7) |
5 | err: `expected `fn` or `{`` | 5 | err: `expected `fn` or `{`` |
6 | STRUCT_ITEM@[7; 19) | 6 | STRUCT_ITEM@[7; 19) |
7 | STRUCT_KW@[7; 13) | 7 | STRUCT_KW@[7; 13) |
8 | NAME@[13; 17) | 8 | NAME@[13; 17) |
diff --git a/tests/data/parser/inline/0013_unsafe_block_in_mod.txt b/tests/data/parser/inline/0013_unsafe_block_in_mod.txt index 5ddc1736c..3b56378a3 100644 --- a/tests/data/parser/inline/0013_unsafe_block_in_mod.txt +++ b/tests/data/parser/inline/0013_unsafe_block_in_mod.txt | |||
@@ -11,8 +11,8 @@ FILE@[0; 33) | |||
11 | R_CURLY@[9; 10) | 11 | R_CURLY@[9; 10) |
12 | WHITESPACE@[10; 11) | 12 | WHITESPACE@[10; 11) |
13 | UNSAFE_KW@[11; 17) | 13 | UNSAFE_KW@[11; 17) |
14 | ERROR@[17; 22) | ||
15 | err: `expected `trait`, `impl` or `fn`` | 14 | err: `expected `trait`, `impl` or `fn`` |
15 | ERROR@[17; 22) | ||
16 | WHITESPACE@[17; 18) | 16 | WHITESPACE@[17; 18) |
17 | L_CURLY@[18; 19) | 17 | L_CURLY@[18; 19) |
18 | WHITESPACE@[19; 20) | 18 | WHITESPACE@[19; 20) |
diff --git a/tests/data/parser/inline/0023_array_type_missing_semi.txt b/tests/data/parser/inline/0023_array_type_missing_semi.txt index bb30a2a2a..cc280d5a7 100644 --- a/tests/data/parser/inline/0023_array_type_missing_semi.txt +++ b/tests/data/parser/inline/0023_array_type_missing_semi.txt | |||
@@ -13,16 +13,16 @@ FILE@[0; 18) | |||
13 | L_PAREN@[10; 11) | 13 | L_PAREN@[10; 11) |
14 | R_PAREN@[11; 12) | 14 | R_PAREN@[11; 12) |
15 | WHITESPACE@[12; 13) | 15 | WHITESPACE@[12; 13) |
16 | err: `expected `;` or `]`` | 16 | err: `expected SEMI` |
17 | err: `expected SEMI` | 17 | err: `expected `;` or `]`` |
18 | err: `expected item` | ||
18 | ERROR@[13; 15) | 19 | ERROR@[13; 15) |
19 | err: `expected item` | ||
20 | INT_NUMBER@[13; 15) | 20 | INT_NUMBER@[13; 15) |
21 | err: `expected item` | ||
21 | ERROR@[15; 16) | 22 | ERROR@[15; 16) |
22 | err: `expected item` | ||
23 | R_BRACK@[15; 16) | 23 | R_BRACK@[15; 16) |
24 | ERROR@[16; 18) | 24 | err: `expected item, found `;` |
25 | err: `expected item, found `;` | ||
26 | consider removing this semicolon` | 25 | consider removing this semicolon` |
26 | ERROR@[16; 18) | ||
27 | SEMI@[16; 17) | 27 | SEMI@[16; 17) |
28 | WHITESPACE@[17; 18) | 28 | WHITESPACE@[17; 18) |
diff --git a/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt b/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt index dd6e24096..d6c27cf58 100644 --- a/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt +++ b/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt | |||
@@ -8,17 +8,17 @@ FILE@[0; 20) | |||
8 | EQ@[7; 8) | 8 | EQ@[7; 8) |
9 | WHITESPACE@[8; 9) | 9 | WHITESPACE@[8; 9) |
10 | UNSAFE_KW@[9; 15) | 10 | UNSAFE_KW@[9; 15) |
11 | err: `expected `fn`` | ||
12 | err: `expected SEMI` | 11 | err: `expected SEMI` |
12 | err: `expected `fn`` | ||
13 | WHITESPACE@[15; 16) | 13 | WHITESPACE@[15; 16) |
14 | err: `expected item` | ||
14 | ERROR@[16; 17) | 15 | ERROR@[16; 17) |
15 | err: `expected item` | ||
16 | L_PAREN@[16; 17) | 16 | L_PAREN@[16; 17) |
17 | err: `expected item` | ||
17 | ERROR@[17; 18) | 18 | ERROR@[17; 18) |
18 | err: `expected item` | ||
19 | R_PAREN@[17; 18) | 19 | R_PAREN@[17; 18) |
20 | ERROR@[18; 20) | 20 | err: `expected item, found `;` |
21 | err: `expected item, found `;` | ||
22 | consider removing this semicolon` | 21 | consider removing this semicolon` |
22 | ERROR@[18; 20) | ||
23 | SEMI@[18; 19) | 23 | SEMI@[18; 19) |
24 | WHITESPACE@[19; 20) | 24 | WHITESPACE@[19; 20) |
diff --git a/tests/parser.rs b/tests/parser.rs index 68a6434be..35b91436a 100644 --- a/tests/parser.rs +++ b/tests/parser.rs | |||
@@ -1,15 +1,15 @@ | |||
1 | extern crate libsyntax2; | 1 | extern crate libsyntax2; |
2 | extern crate testutils; | 2 | extern crate testutils; |
3 | 3 | ||
4 | use libsyntax2::{parse, tokenize}; | 4 | use libsyntax2::{parse, tokenize, parse_green}; |
5 | use libsyntax2::utils::dump_tree; | 5 | use libsyntax2::utils::{dump_tree, dump_tree_green}; |
6 | use testutils::dir_tests; | 6 | use testutils::dir_tests; |
7 | 7 | ||
8 | #[test] | 8 | #[test] |
9 | fn parser_tests() { | 9 | fn parser_tests() { |
10 | dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { | 10 | dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { |
11 | let tokens = tokenize(text); | 11 | let tokens = tokenize(text); |
12 | let file = parse(text.to_string(), &tokens); | 12 | let file = parse_green(text.to_string(), &tokens); |
13 | dump_tree(&file) | 13 | dump_tree_green(&file) |
14 | }) | 14 | }) |
15 | } | 15 | } |