diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-04 09:29:21 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-02-04 09:29:21 +0000 |
commit | 5e5313a7c71d8aa873b418575f56d23b2eac6e7f (patch) | |
tree | 29e5405764acd85642119740e56cde2cb2c2eb5b | |
parent | 75b59bf519b8dcf1a89327d871dab2c98af61ed9 (diff) | |
parent | 003ea633e9e9fbd3e30aec2c6f33589aa13b000a (diff) |
Merge #40
40: Add more inline tests r=matklad a=matklad
-rw-r--r-- | src/parser/event_parser/grammar/items/mod.rs | 8 | ||||
-rw-r--r-- | tests/data/parser/inline/0003_extern_block.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0003_extern_block.txt | 8 | ||||
-rw-r--r-- | tests/data/parser/inline/0004_extern_fn.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0004_extern_fn.txt | 14 | ||||
-rw-r--r-- | tests/data/parser/inline/0005_extern_crate.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0005_extern_crate.txt | 9 | ||||
-rw-r--r-- | tests/data/parser/inline/0006_extern_struct.rs | 1 | ||||
-rw-r--r-- | tests/data/parser/inline/0006_extern_struct.txt | 11 |
9 files changed, 54 insertions, 0 deletions
diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs index 5cf2fc39a..6d6fabbd7 100644 --- a/src/parser/event_parser/grammar/items/mod.rs +++ b/src/parser/event_parser/grammar/items/mod.rs | |||
@@ -25,6 +25,8 @@ fn item(p: &mut Parser) { | |||
25 | use_item::use_item(p); | 25 | use_item::use_item(p); |
26 | USE_ITEM | 26 | USE_ITEM |
27 | } | 27 | } |
28 | // test extern_crate | ||
29 | // extern crate foo; | ||
28 | EXTERN_KW if la == CRATE_KW => { | 30 | EXTERN_KW if la == CRATE_KW => { |
29 | extern_crate_item(p); | 31 | extern_crate_item(p); |
30 | EXTERN_CRATE_ITEM | 32 | EXTERN_CRATE_ITEM |
@@ -32,14 +34,20 @@ fn item(p: &mut Parser) { | |||
32 | EXTERN_KW => { | 34 | EXTERN_KW => { |
33 | abi(p); | 35 | abi(p); |
34 | match p.current() { | 36 | match p.current() { |
37 | // test extern_fn | ||
38 | // extern fn foo() {} | ||
35 | FN_KW => { | 39 | FN_KW => { |
36 | fn_item(p); | 40 | fn_item(p); |
37 | FN_ITEM | 41 | FN_ITEM |
38 | } | 42 | } |
43 | // test extern_block | ||
44 | // extern {} | ||
39 | L_CURLY => { | 45 | L_CURLY => { |
40 | extern_block(p); | 46 | extern_block(p); |
41 | EXTERN_BLOCK | 47 | EXTERN_BLOCK |
42 | } | 48 | } |
49 | // test extern_struct | ||
50 | // extern struct Foo; | ||
43 | _ => { | 51 | _ => { |
44 | item.abandon(p); | 52 | item.abandon(p); |
45 | p.error().message("expected `fn` or `{`").emit(); | 53 | p.error().message("expected `fn` or `{`").emit(); |
diff --git a/tests/data/parser/inline/0003_extern_block.rs b/tests/data/parser/inline/0003_extern_block.rs new file mode 100644 index 000000000..26a9ccd1e --- /dev/null +++ b/tests/data/parser/inline/0003_extern_block.rs | |||
@@ -0,0 +1 @@ | |||
extern {} | |||
diff --git a/tests/data/parser/inline/0003_extern_block.txt b/tests/data/parser/inline/0003_extern_block.txt new file mode 100644 index 000000000..588502932 --- /dev/null +++ b/tests/data/parser/inline/0003_extern_block.txt | |||
@@ -0,0 +1,8 @@ | |||
1 | FILE@[0; 10) | ||
2 | EXTERN_BLOCK@[0; 10) | ||
3 | ABI@[0; 7) | ||
4 | EXTERN_KW@[0; 6) | ||
5 | WHITESPACE@[6; 7) | ||
6 | L_CURLY@[7; 8) | ||
7 | R_CURLY@[8; 9) | ||
8 | WHITESPACE@[9; 10) | ||
diff --git a/tests/data/parser/inline/0004_extern_fn.rs b/tests/data/parser/inline/0004_extern_fn.rs new file mode 100644 index 000000000..394a049f0 --- /dev/null +++ b/tests/data/parser/inline/0004_extern_fn.rs | |||
@@ -0,0 +1 @@ | |||
extern fn foo() {} | |||
diff --git a/tests/data/parser/inline/0004_extern_fn.txt b/tests/data/parser/inline/0004_extern_fn.txt new file mode 100644 index 000000000..096c3bf4f --- /dev/null +++ b/tests/data/parser/inline/0004_extern_fn.txt | |||
@@ -0,0 +1,14 @@ | |||
1 | FILE@[0; 19) | ||
2 | FN_ITEM@[0; 19) | ||
3 | ABI@[0; 7) | ||
4 | EXTERN_KW@[0; 6) | ||
5 | WHITESPACE@[6; 7) | ||
6 | FN_KW@[7; 9) | ||
7 | WHITESPACE@[9; 10) | ||
8 | IDENT@[10; 13) "foo" | ||
9 | L_PAREN@[13; 14) | ||
10 | R_PAREN@[14; 15) | ||
11 | WHITESPACE@[15; 16) | ||
12 | L_CURLY@[16; 17) | ||
13 | R_CURLY@[17; 18) | ||
14 | WHITESPACE@[18; 19) | ||
diff --git a/tests/data/parser/inline/0005_extern_crate.rs b/tests/data/parser/inline/0005_extern_crate.rs new file mode 100644 index 000000000..49af74e1b --- /dev/null +++ b/tests/data/parser/inline/0005_extern_crate.rs | |||
@@ -0,0 +1 @@ | |||
extern crate foo; | |||
diff --git a/tests/data/parser/inline/0005_extern_crate.txt b/tests/data/parser/inline/0005_extern_crate.txt new file mode 100644 index 000000000..07cc47875 --- /dev/null +++ b/tests/data/parser/inline/0005_extern_crate.txt | |||
@@ -0,0 +1,9 @@ | |||
1 | FILE@[0; 18) | ||
2 | EXTERN_CRATE_ITEM@[0; 18) | ||
3 | EXTERN_KW@[0; 6) | ||
4 | WHITESPACE@[6; 7) | ||
5 | CRATE_KW@[7; 12) | ||
6 | WHITESPACE@[12; 13) | ||
7 | IDENT@[13; 16) "foo" | ||
8 | SEMI@[16; 17) | ||
9 | WHITESPACE@[17; 18) | ||
diff --git a/tests/data/parser/inline/0006_extern_struct.rs b/tests/data/parser/inline/0006_extern_struct.rs new file mode 100644 index 000000000..c1bd0a2d1 --- /dev/null +++ b/tests/data/parser/inline/0006_extern_struct.rs | |||
@@ -0,0 +1 @@ | |||
extern struct Foo; | |||
diff --git a/tests/data/parser/inline/0006_extern_struct.txt b/tests/data/parser/inline/0006_extern_struct.txt new file mode 100644 index 000000000..13917d7f3 --- /dev/null +++ b/tests/data/parser/inline/0006_extern_struct.txt | |||
@@ -0,0 +1,11 @@ | |||
1 | FILE@[0; 19) | ||
2 | ABI@[0; 7) | ||
3 | EXTERN_KW@[0; 6) | ||
4 | WHITESPACE@[6; 7) | ||
5 | err: `expected `fn` or `{`` | ||
6 | STRUCT_ITEM@[7; 19) | ||
7 | STRUCT_KW@[7; 13) | ||
8 | WHITESPACE@[13; 14) | ||
9 | IDENT@[14; 17) "Foo" | ||
10 | SEMI@[17; 18) | ||
11 | WHITESPACE@[18; 19) | ||