diff options
author | Dylan MacKenzie <[email protected]> | 2019-09-15 00:00:21 +0100 |
---|---|---|
committer | Dylan MacKenzie <[email protected]> | 2019-09-15 00:31:09 +0100 |
commit | c413f444a02ad7898b7a259e0d7aeaed91fd1997 (patch) | |
tree | e65797200723aeb35afc10acb24a7a7d385d5c2b /crates/ra_syntax | |
parent | 253a18f93893ffa0e2804937c913fed84df5f8d3 (diff) |
Add tests for underscores in `const` and `static` items
Diffstat (limited to 'crates/ra_syntax')
3 files changed, 78 insertions, 38 deletions
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt new file mode 100644 index 000000000..28f75a341 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | SOURCE_FILE@[0; 19) | ||
2 | STATIC_DEF@[0; 18) | ||
3 | STATIC_KW@[0; 6) "static" | ||
4 | WHITESPACE@[6; 7) " " | ||
5 | ERROR@[7; 8) | ||
6 | UNDERSCORE@[7; 8) "_" | ||
7 | COLON@[8; 9) ":" | ||
8 | WHITESPACE@[9; 10) " " | ||
9 | PATH_TYPE@[10; 13) | ||
10 | PATH@[10; 13) | ||
11 | PATH_SEGMENT@[10; 13) | ||
12 | NAME_REF@[10; 13) | ||
13 | IDENT@[10; 13) "i32" | ||
14 | WHITESPACE@[13; 14) " " | ||
15 | EQ@[14; 15) "=" | ||
16 | WHITESPACE@[15; 16) " " | ||
17 | LITERAL@[16; 17) | ||
18 | INT_NUMBER@[16; 17) "5" | ||
19 | SEMI@[17; 18) ";" | ||
20 | WHITESPACE@[18; 19) "\n" | ||
21 | error 7: expected a name | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rs b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rs index 7446859b5..a806a209d 100644 --- a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rs +++ b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rs | |||
@@ -1,2 +1,3 @@ | |||
1 | const _: u32 = 0; | ||
1 | const FOO: u32 = 92; | 2 | const FOO: u32 = 92; |
2 | const mut BAR: u32 = 62; | 3 | const mut BAR: u32 = 62; |
diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.txt b/crates/ra_syntax/test_data/parser/ok/0024_const_item.txt index dea8a3a97..abe9f851b 100644 --- a/crates/ra_syntax/test_data/parser/ok/0024_const_item.txt +++ b/crates/ra_syntax/test_data/parser/ok/0024_const_item.txt | |||
@@ -1,41 +1,59 @@ | |||
1 | SOURCE_FILE@[0; 46) | 1 | SOURCE_FILE@[0; 64) |
2 | CONST_DEF@[0; 20) | 2 | CONST_DEF@[0; 17) |
3 | CONST_KW@[0; 5) "const" | 3 | CONST_KW@[0; 5) "const" |
4 | WHITESPACE@[5; 6) " " | 4 | WHITESPACE@[5; 6) " " |
5 | NAME@[6; 9) | 5 | UNDERSCORE@[6; 7) "_" |
6 | IDENT@[6; 9) "FOO" | 6 | COLON@[7; 8) ":" |
7 | COLON@[9; 10) ":" | 7 | WHITESPACE@[8; 9) " " |
8 | WHITESPACE@[10; 11) " " | 8 | PATH_TYPE@[9; 12) |
9 | PATH_TYPE@[11; 14) | 9 | PATH@[9; 12) |
10 | PATH@[11; 14) | 10 | PATH_SEGMENT@[9; 12) |
11 | PATH_SEGMENT@[11; 14) | 11 | NAME_REF@[9; 12) |
12 | NAME_REF@[11; 14) | 12 | IDENT@[9; 12) "u32" |
13 | IDENT@[11; 14) "u32" | 13 | WHITESPACE@[12; 13) " " |
14 | EQ@[13; 14) "=" | ||
14 | WHITESPACE@[14; 15) " " | 15 | WHITESPACE@[14; 15) " " |
15 | EQ@[15; 16) "=" | 16 | LITERAL@[15; 16) |
16 | WHITESPACE@[16; 17) " " | 17 | INT_NUMBER@[15; 16) "0" |
17 | LITERAL@[17; 19) | 18 | SEMI@[16; 17) ";" |
18 | INT_NUMBER@[17; 19) "92" | 19 | WHITESPACE@[17; 18) "\n" |
19 | SEMI@[19; 20) ";" | 20 | CONST_DEF@[18; 38) |
20 | WHITESPACE@[20; 21) "\n" | 21 | CONST_KW@[18; 23) "const" |
21 | CONST_DEF@[21; 45) | 22 | WHITESPACE@[23; 24) " " |
22 | CONST_KW@[21; 26) "const" | 23 | NAME@[24; 27) |
23 | WHITESPACE@[26; 27) " " | 24 | IDENT@[24; 27) "FOO" |
24 | MUT_KW@[27; 30) "mut" | 25 | COLON@[27; 28) ":" |
25 | WHITESPACE@[30; 31) " " | 26 | WHITESPACE@[28; 29) " " |
26 | NAME@[31; 34) | 27 | PATH_TYPE@[29; 32) |
27 | IDENT@[31; 34) "BAR" | 28 | PATH@[29; 32) |
28 | COLON@[34; 35) ":" | 29 | PATH_SEGMENT@[29; 32) |
29 | WHITESPACE@[35; 36) " " | 30 | NAME_REF@[29; 32) |
30 | PATH_TYPE@[36; 39) | 31 | IDENT@[29; 32) "u32" |
31 | PATH@[36; 39) | 32 | WHITESPACE@[32; 33) " " |
32 | PATH_SEGMENT@[36; 39) | 33 | EQ@[33; 34) "=" |
33 | NAME_REF@[36; 39) | 34 | WHITESPACE@[34; 35) " " |
34 | IDENT@[36; 39) "u32" | 35 | LITERAL@[35; 37) |
35 | WHITESPACE@[39; 40) " " | 36 | INT_NUMBER@[35; 37) "92" |
36 | EQ@[40; 41) "=" | 37 | SEMI@[37; 38) ";" |
37 | WHITESPACE@[41; 42) " " | 38 | WHITESPACE@[38; 39) "\n" |
38 | LITERAL@[42; 44) | 39 | CONST_DEF@[39; 63) |
39 | INT_NUMBER@[42; 44) "62" | 40 | CONST_KW@[39; 44) "const" |
40 | SEMI@[44; 45) ";" | 41 | WHITESPACE@[44; 45) " " |
41 | WHITESPACE@[45; 46) "\n" | 42 | MUT_KW@[45; 48) "mut" |
43 | WHITESPACE@[48; 49) " " | ||
44 | NAME@[49; 52) | ||
45 | IDENT@[49; 52) "BAR" | ||
46 | COLON@[52; 53) ":" | ||
47 | WHITESPACE@[53; 54) " " | ||
48 | PATH_TYPE@[54; 57) | ||
49 | PATH@[54; 57) | ||
50 | PATH_SEGMENT@[54; 57) | ||
51 | NAME_REF@[54; 57) | ||
52 | IDENT@[54; 57) "u32" | ||
53 | WHITESPACE@[57; 58) " " | ||
54 | EQ@[58; 59) "=" | ||
55 | WHITESPACE@[59; 60) " " | ||
56 | LITERAL@[60; 62) | ||
57 | INT_NUMBER@[60; 62) "62" | ||
58 | SEMI@[62; 63) ";" | ||
59 | WHITESPACE@[63; 64) "\n" | ||