From 003ea633e9e9fbd3e30aec2c6f33589aa13b000a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 4 Feb 2018 12:28:30 +0300 Subject: Add more inline tests --- src/parser/event_parser/grammar/items/mod.rs | 8 ++++++++ tests/data/parser/inline/0003_extern_block.rs | 1 + tests/data/parser/inline/0003_extern_block.txt | 8 ++++++++ tests/data/parser/inline/0004_extern_fn.rs | 1 + tests/data/parser/inline/0004_extern_fn.txt | 14 ++++++++++++++ tests/data/parser/inline/0005_extern_crate.rs | 1 + tests/data/parser/inline/0005_extern_crate.txt | 9 +++++++++ tests/data/parser/inline/0006_extern_struct.rs | 1 + tests/data/parser/inline/0006_extern_struct.txt | 11 +++++++++++ 9 files changed, 54 insertions(+) create mode 100644 tests/data/parser/inline/0003_extern_block.rs create mode 100644 tests/data/parser/inline/0003_extern_block.txt create mode 100644 tests/data/parser/inline/0004_extern_fn.rs create mode 100644 tests/data/parser/inline/0004_extern_fn.txt create mode 100644 tests/data/parser/inline/0005_extern_crate.rs create mode 100644 tests/data/parser/inline/0005_extern_crate.txt create mode 100644 tests/data/parser/inline/0006_extern_struct.rs create mode 100644 tests/data/parser/inline/0006_extern_struct.txt 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) { use_item::use_item(p); USE_ITEM } + // test extern_crate + // extern crate foo; EXTERN_KW if la == CRATE_KW => { extern_crate_item(p); EXTERN_CRATE_ITEM @@ -32,14 +34,20 @@ fn item(p: &mut Parser) { EXTERN_KW => { abi(p); match p.current() { + // test extern_fn + // extern fn foo() {} FN_KW => { fn_item(p); FN_ITEM } + // test extern_block + // extern {} L_CURLY => { extern_block(p); EXTERN_BLOCK } + // test extern_struct + // extern struct Foo; _ => { item.abandon(p); 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 @@ +FILE@[0; 10) + EXTERN_BLOCK@[0; 10) + ABI@[0; 7) + EXTERN_KW@[0; 6) + WHITESPACE@[6; 7) + L_CURLY@[7; 8) + R_CURLY@[8; 9) + 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 @@ +FILE@[0; 19) + FN_ITEM@[0; 19) + ABI@[0; 7) + EXTERN_KW@[0; 6) + WHITESPACE@[6; 7) + FN_KW@[7; 9) + WHITESPACE@[9; 10) + IDENT@[10; 13) "foo" + L_PAREN@[13; 14) + R_PAREN@[14; 15) + WHITESPACE@[15; 16) + L_CURLY@[16; 17) + R_CURLY@[17; 18) + 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 @@ +FILE@[0; 18) + EXTERN_CRATE_ITEM@[0; 18) + EXTERN_KW@[0; 6) + WHITESPACE@[6; 7) + CRATE_KW@[7; 12) + WHITESPACE@[12; 13) + IDENT@[13; 16) "foo" + SEMI@[16; 17) + 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 @@ +FILE@[0; 19) + ABI@[0; 7) + EXTERN_KW@[0; 6) + WHITESPACE@[6; 7) + err: `expected `fn` or `{`` + STRUCT_ITEM@[7; 19) + STRUCT_KW@[7; 13) + WHITESPACE@[13; 14) + IDENT@[14; 17) "Foo" + SEMI@[17; 18) + WHITESPACE@[18; 19) -- cgit v1.2.3