diff options
Diffstat (limited to 'crates/libsyntax2/tests')
5 files changed, 56 insertions, 4 deletions
diff --git a/crates/libsyntax2/tests/data/parser/err/0007_stray_curly_in_file.txt b/crates/libsyntax2/tests/data/parser/err/0007_stray_curly_in_file.txt index 81e82f7e2..802c69b31 100644 --- a/crates/libsyntax2/tests/data/parser/err/0007_stray_curly_in_file.txt +++ b/crates/libsyntax2/tests/data/parser/err/0007_stray_curly_in_file.txt | |||
@@ -1,7 +1,7 @@ | |||
1 | ROOT@[0; 31) | 1 | ROOT@[0; 31) |
2 | ERROR@[0; 1) | 2 | ERROR@[0; 1) |
3 | R_CURLY@[0; 1) | 3 | R_CURLY@[0; 1) |
4 | err: `expected an item` | 4 | err: `unmatched `}`` |
5 | WHITESPACE@[1; 3) | 5 | WHITESPACE@[1; 3) |
6 | STRUCT_DEF@[3; 12) | 6 | STRUCT_DEF@[3; 12) |
7 | STRUCT_KW@[3; 9) | 7 | STRUCT_KW@[3; 9) |
@@ -10,7 +10,7 @@ ROOT@[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 an item` | 13 | err: `unmatched `}`` |
14 | ERROR@[14; 15) | 14 | ERROR@[14; 15) |
15 | R_CURLY@[14; 15) | 15 | R_CURLY@[14; 15) |
16 | WHITESPACE@[15; 17) | 16 | WHITESPACE@[15; 17) |
@@ -26,7 +26,7 @@ ROOT@[0; 31) | |||
26 | L_CURLY@[25; 26) | 26 | L_CURLY@[25; 26) |
27 | R_CURLY@[26; 27) | 27 | R_CURLY@[26; 27) |
28 | WHITESPACE@[27; 29) | 28 | WHITESPACE@[27; 29) |
29 | err: `expected an item` | 29 | err: `unmatched `}`` |
30 | ERROR@[29; 30) | 30 | ERROR@[29; 30) |
31 | R_CURLY@[29; 30) | 31 | R_CURLY@[29; 30) |
32 | WHITESPACE@[30; 31) | 32 | WHITESPACE@[30; 31) |
diff --git a/crates/libsyntax2/tests/data/parser/err/0015_curly_in_params.txt b/crates/libsyntax2/tests/data/parser/err/0015_curly_in_params.txt index dbc19abea..5f736a978 100644 --- a/crates/libsyntax2/tests/data/parser/err/0015_curly_in_params.txt +++ b/crates/libsyntax2/tests/data/parser/err/0015_curly_in_params.txt | |||
@@ -9,7 +9,7 @@ ROOT@[0; 14) | |||
9 | err: `expected value parameter` | 9 | err: `expected value parameter` |
10 | err: `expected R_PAREN` | 10 | err: `expected R_PAREN` |
11 | err: `expected a block` | 11 | err: `expected a block` |
12 | err: `expected an item` | 12 | err: `unmatched `}`` |
13 | ERROR@[7; 8) | 13 | ERROR@[7; 8) |
14 | R_CURLY@[7; 8) | 14 | R_CURLY@[7; 8) |
15 | err: `expected an item` | 15 | err: `expected an item` |
diff --git a/crates/libsyntax2/tests/data/parser/err/0017_incomplete_binexpr.rs b/crates/libsyntax2/tests/data/parser/err/0017_incomplete_binexpr.rs new file mode 100644 index 000000000..17bd49777 --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/err/0017_incomplete_binexpr.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | fn foo(foo: i32) { | ||
2 | let bar = 92; | ||
3 | 1 + | ||
4 | } | ||
diff --git a/crates/libsyntax2/tests/data/parser/err/0017_incomplete_binexpr.txt b/crates/libsyntax2/tests/data/parser/err/0017_incomplete_binexpr.txt new file mode 100644 index 000000000..db9a2f175 --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/err/0017_incomplete_binexpr.txt | |||
@@ -0,0 +1,47 @@ | |||
1 | ROOT@[0; 47) | ||
2 | FN_DEF@[0; 46) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 6) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 16) | ||
8 | L_PAREN@[6; 7) | ||
9 | PARAM@[7; 15) | ||
10 | BIND_PAT@[7; 10) | ||
11 | NAME@[7; 10) | ||
12 | IDENT@[7; 10) "foo" | ||
13 | COLON@[10; 11) | ||
14 | WHITESPACE@[11; 12) | ||
15 | PATH_TYPE@[12; 15) | ||
16 | PATH@[12; 15) | ||
17 | PATH_SEGMENT@[12; 15) | ||
18 | NAME_REF@[12; 15) | ||
19 | IDENT@[12; 15) "i32" | ||
20 | R_PAREN@[15; 16) | ||
21 | WHITESPACE@[16; 17) | ||
22 | BLOCK@[17; 46) | ||
23 | L_CURLY@[17; 18) | ||
24 | WHITESPACE@[18; 23) | ||
25 | LET_STMT@[23; 36) | ||
26 | LET_KW@[23; 26) | ||
27 | WHITESPACE@[26; 27) | ||
28 | BIND_PAT@[27; 30) | ||
29 | NAME@[27; 30) | ||
30 | IDENT@[27; 30) "bar" | ||
31 | WHITESPACE@[30; 31) | ||
32 | EQ@[31; 32) | ||
33 | WHITESPACE@[32; 33) | ||
34 | LITERAL@[33; 35) | ||
35 | INT_NUMBER@[33; 35) "92" | ||
36 | SEMI@[35; 36) | ||
37 | WHITESPACE@[36; 41) | ||
38 | BIN_EXPR@[41; 45) | ||
39 | LITERAL@[41; 42) | ||
40 | INT_NUMBER@[41; 42) "1" | ||
41 | WHITESPACE@[42; 43) | ||
42 | PLUS@[43; 44) | ||
43 | WHITESPACE@[44; 45) | ||
44 | err: `expected expression` | ||
45 | ERROR@[45; 45) | ||
46 | R_CURLY@[45; 46) | ||
47 | WHITESPACE@[46; 47) | ||
diff --git a/crates/libsyntax2/tests/test/main.rs b/crates/libsyntax2/tests/test/main.rs index 596f32216..9958c7ece 100644 --- a/crates/libsyntax2/tests/test/main.rs +++ b/crates/libsyntax2/tests/test/main.rs | |||
@@ -26,6 +26,7 @@ fn lexer_tests() { | |||
26 | #[test] | 26 | #[test] |
27 | fn parser_tests() { | 27 | fn parser_tests() { |
28 | dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { | 28 | dir_tests(&["parser/inline", "parser/ok", "parser/err"], |text| { |
29 | eprintln!("\n{}\n", text); | ||
29 | let file = File::parse(text); | 30 | let file = File::parse(text); |
30 | dump_tree(file.syntax()) | 31 | dump_tree(file.syntax()) |
31 | }) | 32 | }) |