From 2389cf96dd07d8c94da349b10f6f2b750707dfd9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 11:01:00 +0300 Subject: G: Never type --- tests/data/parser/inline/0020_never_type.rs | 1 + tests/data/parser/inline/0020_never_type.txt | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/data/parser/inline/0020_never_type.rs create mode 100644 tests/data/parser/inline/0020_never_type.txt (limited to 'tests') diff --git a/tests/data/parser/inline/0020_never_type.rs b/tests/data/parser/inline/0020_never_type.rs new file mode 100644 index 000000000..de399fcf4 --- /dev/null +++ b/tests/data/parser/inline/0020_never_type.rs @@ -0,0 +1 @@ +type Never = !; diff --git a/tests/data/parser/inline/0020_never_type.txt b/tests/data/parser/inline/0020_never_type.txt new file mode 100644 index 000000000..935f33459 --- /dev/null +++ b/tests/data/parser/inline/0020_never_type.txt @@ -0,0 +1,13 @@ +FILE@[0; 16) + TYPE_ITEM@[0; 16) + TYPE_KW@[0; 4) + NAME@[4; 11) + WHITESPACE@[4; 5) + IDENT@[5; 10) "Never" + WHITESPACE@[10; 11) + EQ@[11; 12) + NEVER_TYPE@[12; 14) + WHITESPACE@[12; 13) + EXCL@[13; 14) + SEMI@[14; 15) + WHITESPACE@[15; 16) -- cgit v1.2.3 From ceb94ece2aa6a1b54063c582663fff4c1937d989 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 11:19:54 +0300 Subject: G: pointer types --- .../inline/0021_pointer_type_no_mutability.rs | 1 + .../inline/0021_pointer_type_no_mutability.txt | 17 +++++++++++ tests/data/parser/inline/0022_pointer_type_mut.rs | 2 ++ tests/data/parser/inline/0022_pointer_type_mut.txt | 35 ++++++++++++++++++++++ tests/testutils/src/lib.rs | 15 +++++----- 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 tests/data/parser/inline/0021_pointer_type_no_mutability.rs create mode 100644 tests/data/parser/inline/0021_pointer_type_no_mutability.txt create mode 100644 tests/data/parser/inline/0022_pointer_type_mut.rs create mode 100644 tests/data/parser/inline/0022_pointer_type_mut.txt (limited to 'tests') diff --git a/tests/data/parser/inline/0021_pointer_type_no_mutability.rs b/tests/data/parser/inline/0021_pointer_type_no_mutability.rs new file mode 100644 index 000000000..fae705131 --- /dev/null +++ b/tests/data/parser/inline/0021_pointer_type_no_mutability.rs @@ -0,0 +1 @@ +type T = *(); diff --git a/tests/data/parser/inline/0021_pointer_type_no_mutability.txt b/tests/data/parser/inline/0021_pointer_type_no_mutability.txt new file mode 100644 index 000000000..f7720a712 --- /dev/null +++ b/tests/data/parser/inline/0021_pointer_type_no_mutability.txt @@ -0,0 +1,17 @@ +FILE@[0; 14) + TYPE_ITEM@[0; 14) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "T" + WHITESPACE@[6; 7) + EQ@[7; 8) + POINTER_TYPE@[8; 12) + WHITESPACE@[8; 9) + STAR@[9; 10) + err: `expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)` + TUPLE_TYPE@[10; 12) + L_PAREN@[10; 11) + R_PAREN@[11; 12) + SEMI@[12; 13) + WHITESPACE@[13; 14) diff --git a/tests/data/parser/inline/0022_pointer_type_mut.rs b/tests/data/parser/inline/0022_pointer_type_mut.rs new file mode 100644 index 000000000..04b2bb9ba --- /dev/null +++ b/tests/data/parser/inline/0022_pointer_type_mut.rs @@ -0,0 +1,2 @@ +type M = *mut (); +type C = *mut (); diff --git a/tests/data/parser/inline/0022_pointer_type_mut.txt b/tests/data/parser/inline/0022_pointer_type_mut.txt new file mode 100644 index 000000000..c3ab2b887 --- /dev/null +++ b/tests/data/parser/inline/0022_pointer_type_mut.txt @@ -0,0 +1,35 @@ +FILE@[0; 36) + TYPE_ITEM@[0; 18) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "M" + WHITESPACE@[6; 7) + EQ@[7; 8) + POINTER_TYPE@[8; 16) + WHITESPACE@[8; 9) + STAR@[9; 10) + MUT_KW@[10; 13) + TUPLE_TYPE@[13; 16) + WHITESPACE@[13; 14) + L_PAREN@[14; 15) + R_PAREN@[15; 16) + SEMI@[16; 17) + WHITESPACE@[17; 18) + TYPE_ITEM@[18; 36) + TYPE_KW@[18; 22) + NAME@[22; 25) + WHITESPACE@[22; 23) + IDENT@[23; 24) "C" + WHITESPACE@[24; 25) + EQ@[25; 26) + POINTER_TYPE@[26; 34) + WHITESPACE@[26; 27) + STAR@[27; 28) + MUT_KW@[28; 31) + TUPLE_TYPE@[31; 34) + WHITESPACE@[31; 32) + L_PAREN@[32; 33) + R_PAREN@[33; 34) + SEMI@[34; 35) + WHITESPACE@[35; 36) diff --git a/tests/testutils/src/lib.rs b/tests/testutils/src/lib.rs index b50e70849..ae1dea810 100644 --- a/tests/testutils/src/lib.rs +++ b/tests/testutils/src/lib.rs @@ -26,21 +26,20 @@ where F: Fn(&str) -> String, { for path in collect_tests(paths) { - let actual = { - let text = read_text(&path); - f(&text) - }; + let input_code = read_text(&path); + let parse_tree = f(&input_code); let path = path.with_extension("txt"); if !path.exists() { println!("\nfile: {}", path.display()); - println!("No .txt file with expected result, creating..."); - file::put_text(&path, actual).unwrap(); + println!("No .txt file with expected result, creating...\n"); + println!("{}\n{}", input_code, parse_tree); + file::put_text(&path, parse_tree).unwrap(); panic!("No expected result") } let expected = read_text(&path); let expected = expected.as_str(); - let actual = actual.as_str(); - assert_equal_text(expected, actual, &path); + let parse_tree = parse_tree.as_str(); + assert_equal_text(expected, parse_tree, &path); } } -- cgit v1.2.3 From 555c4ae37560493fd901aad41951ad1664043459 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 11:37:08 +0300 Subject: G: slice & array types --- .../parser/inline/0023_array_type_missing_semi.rs | 1 + .../parser/inline/0023_array_type_missing_semi.txt | 28 ++++++++++++++++++++++ tests/data/parser/inline/0024_array_type.rs | 1 + tests/data/parser/inline/0024_array_type.txt | 21 ++++++++++++++++ tests/data/parser/inline/0025_slice_type.rs | 1 + tests/data/parser/inline/0025_slice_type.txt | 17 +++++++++++++ 6 files changed, 69 insertions(+) create mode 100644 tests/data/parser/inline/0023_array_type_missing_semi.rs create mode 100644 tests/data/parser/inline/0023_array_type_missing_semi.txt create mode 100644 tests/data/parser/inline/0024_array_type.rs create mode 100644 tests/data/parser/inline/0024_array_type.txt create mode 100644 tests/data/parser/inline/0025_slice_type.rs create mode 100644 tests/data/parser/inline/0025_slice_type.txt (limited to 'tests') diff --git a/tests/data/parser/inline/0023_array_type_missing_semi.rs b/tests/data/parser/inline/0023_array_type_missing_semi.rs new file mode 100644 index 000000000..a94851443 --- /dev/null +++ b/tests/data/parser/inline/0023_array_type_missing_semi.rs @@ -0,0 +1 @@ +type T = [() 92]; diff --git a/tests/data/parser/inline/0023_array_type_missing_semi.txt b/tests/data/parser/inline/0023_array_type_missing_semi.txt new file mode 100644 index 000000000..bb30a2a2a --- /dev/null +++ b/tests/data/parser/inline/0023_array_type_missing_semi.txt @@ -0,0 +1,28 @@ +FILE@[0; 18) + TYPE_ITEM@[0; 13) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "T" + WHITESPACE@[6; 7) + EQ@[7; 8) + SLICE_TYPE@[8; 13) + WHITESPACE@[8; 9) + L_BRACK@[9; 10) + TUPLE_TYPE@[10; 13) + L_PAREN@[10; 11) + R_PAREN@[11; 12) + WHITESPACE@[12; 13) + err: `expected `;` or `]`` + err: `expected SEMI` + ERROR@[13; 15) + err: `expected item` + INT_NUMBER@[13; 15) + ERROR@[15; 16) + err: `expected item` + R_BRACK@[15; 16) + ERROR@[16; 18) + err: `expected item, found `;` +consider removing this semicolon` + SEMI@[16; 17) + WHITESPACE@[17; 18) diff --git a/tests/data/parser/inline/0024_array_type.rs b/tests/data/parser/inline/0024_array_type.rs new file mode 100644 index 000000000..27eb22f22 --- /dev/null +++ b/tests/data/parser/inline/0024_array_type.rs @@ -0,0 +1 @@ +type T = [(); 92]; diff --git a/tests/data/parser/inline/0024_array_type.txt b/tests/data/parser/inline/0024_array_type.txt new file mode 100644 index 000000000..970734a19 --- /dev/null +++ b/tests/data/parser/inline/0024_array_type.txt @@ -0,0 +1,21 @@ +FILE@[0; 19) + TYPE_ITEM@[0; 19) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "T" + WHITESPACE@[6; 7) + EQ@[7; 8) + ARRAY_TYPE@[8; 17) + WHITESPACE@[8; 9) + L_BRACK@[9; 10) + TUPLE_TYPE@[10; 12) + L_PAREN@[10; 11) + R_PAREN@[11; 12) + SEMI@[12; 13) + LITERAL@[13; 16) + WHITESPACE@[13; 14) + INT_NUMBER@[14; 16) + R_BRACK@[16; 17) + SEMI@[17; 18) + WHITESPACE@[18; 19) diff --git a/tests/data/parser/inline/0025_slice_type.rs b/tests/data/parser/inline/0025_slice_type.rs new file mode 100644 index 000000000..4da1af827 --- /dev/null +++ b/tests/data/parser/inline/0025_slice_type.rs @@ -0,0 +1 @@ +type T = [()]; diff --git a/tests/data/parser/inline/0025_slice_type.txt b/tests/data/parser/inline/0025_slice_type.txt new file mode 100644 index 000000000..22938e5e1 --- /dev/null +++ b/tests/data/parser/inline/0025_slice_type.txt @@ -0,0 +1,17 @@ +FILE@[0; 15) + TYPE_ITEM@[0; 15) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "T" + WHITESPACE@[6; 7) + EQ@[7; 8) + SLICE_TYPE@[8; 13) + WHITESPACE@[8; 9) + L_BRACK@[9; 10) + TUPLE_TYPE@[10; 12) + L_PAREN@[10; 11) + R_PAREN@[11; 12) + R_BRACK@[12; 13) + SEMI@[13; 14) + WHITESPACE@[14; 15) -- cgit v1.2.3 From eb4c05d572ff0c4e92452232d6591d7a2796e785 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 11:54:09 +0300 Subject: G: reference types --- tests/data/parser/inline/0026_reference_type;.rs | 3 ++ tests/data/parser/inline/0026_reference_type;.txt | 50 +++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/data/parser/inline/0026_reference_type;.rs create mode 100644 tests/data/parser/inline/0026_reference_type;.txt (limited to 'tests') diff --git a/tests/data/parser/inline/0026_reference_type;.rs b/tests/data/parser/inline/0026_reference_type;.rs new file mode 100644 index 000000000..3ac0badab --- /dev/null +++ b/tests/data/parser/inline/0026_reference_type;.rs @@ -0,0 +1,3 @@ +type A = &(); +type B = &'static (); +type C = &mut (); diff --git a/tests/data/parser/inline/0026_reference_type;.txt b/tests/data/parser/inline/0026_reference_type;.txt new file mode 100644 index 000000000..665c021e1 --- /dev/null +++ b/tests/data/parser/inline/0026_reference_type;.txt @@ -0,0 +1,50 @@ +FILE@[0; 54) + TYPE_ITEM@[0; 14) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "A" + WHITESPACE@[6; 7) + EQ@[7; 8) + REFERENCE_TYPE@[8; 12) + WHITESPACE@[8; 9) + AMPERSAND@[9; 10) + TUPLE_TYPE@[10; 12) + L_PAREN@[10; 11) + R_PAREN@[11; 12) + SEMI@[12; 13) + WHITESPACE@[13; 14) + TYPE_ITEM@[14; 36) + TYPE_KW@[14; 18) + NAME@[18; 21) + WHITESPACE@[18; 19) + IDENT@[19; 20) "B" + WHITESPACE@[20; 21) + EQ@[21; 22) + REFERENCE_TYPE@[22; 34) + WHITESPACE@[22; 23) + AMPERSAND@[23; 24) + LIFETIME@[24; 31) "'static" + TUPLE_TYPE@[31; 34) + WHITESPACE@[31; 32) + L_PAREN@[32; 33) + R_PAREN@[33; 34) + SEMI@[34; 35) + WHITESPACE@[35; 36) + TYPE_ITEM@[36; 54) + TYPE_KW@[36; 40) + NAME@[40; 43) + WHITESPACE@[40; 41) + IDENT@[41; 42) "C" + WHITESPACE@[42; 43) + EQ@[43; 44) + REFERENCE_TYPE@[44; 52) + WHITESPACE@[44; 45) + AMPERSAND@[45; 46) + MUT_KW@[46; 49) + TUPLE_TYPE@[49; 52) + WHITESPACE@[49; 50) + L_PAREN@[50; 51) + R_PAREN@[51; 52) + SEMI@[52; 53) + WHITESPACE@[53; 54) -- cgit v1.2.3 From 2fb33b2d0d14f09ee06a42bca252dccbf57185e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 11:57:05 +0300 Subject: G: placeholder types --- tests/data/parser/inline/0027_placeholder_type.rs | 1 + tests/data/parser/inline/0027_placeholder_type.txt | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/data/parser/inline/0027_placeholder_type.rs create mode 100644 tests/data/parser/inline/0027_placeholder_type.txt (limited to 'tests') diff --git a/tests/data/parser/inline/0027_placeholder_type.rs b/tests/data/parser/inline/0027_placeholder_type.rs new file mode 100644 index 000000000..7952dbd57 --- /dev/null +++ b/tests/data/parser/inline/0027_placeholder_type.rs @@ -0,0 +1 @@ +type Placeholder = _; diff --git a/tests/data/parser/inline/0027_placeholder_type.txt b/tests/data/parser/inline/0027_placeholder_type.txt new file mode 100644 index 000000000..ab848836c --- /dev/null +++ b/tests/data/parser/inline/0027_placeholder_type.txt @@ -0,0 +1,13 @@ +FILE@[0; 22) + TYPE_ITEM@[0; 22) + TYPE_KW@[0; 4) + NAME@[4; 17) + WHITESPACE@[4; 5) + IDENT@[5; 16) "Placeholder" + WHITESPACE@[16; 17) + EQ@[17; 18) + PLACEHOLDER_TYPE@[18; 20) + WHITESPACE@[18; 19) + UNDERSCORE@[19; 20) + SEMI@[20; 21) + WHITESPACE@[21; 22) -- cgit v1.2.3 From 8a3f17a4e263781deac5e503ad5116ec78004618 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 11 Feb 2018 12:51:09 +0300 Subject: G: fn pointer type --- tests/data/parser/inline/0028_fn_pointer_type.rs | 3 ++ tests/data/parser/inline/0028_fn_pointer_type.txt | 52 ++++++++++++++++++++++ .../inline/0029_fn_pointer_type_missing_fn.rs | 1 + .../inline/0029_fn_pointer_type_missing_fn.txt | 24 ++++++++++ .../parser/inline/0030_fn_pointer_type_with_ret.rs | 1 + .../inline/0030_fn_pointer_type_with_ret.txt | 21 +++++++++ 6 files changed, 102 insertions(+) create mode 100644 tests/data/parser/inline/0028_fn_pointer_type.rs create mode 100644 tests/data/parser/inline/0028_fn_pointer_type.txt create mode 100644 tests/data/parser/inline/0029_fn_pointer_type_missing_fn.rs create mode 100644 tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt create mode 100644 tests/data/parser/inline/0030_fn_pointer_type_with_ret.rs create mode 100644 tests/data/parser/inline/0030_fn_pointer_type_with_ret.txt (limited to 'tests') diff --git a/tests/data/parser/inline/0028_fn_pointer_type.rs b/tests/data/parser/inline/0028_fn_pointer_type.rs new file mode 100644 index 000000000..c9bf3bdb4 --- /dev/null +++ b/tests/data/parser/inline/0028_fn_pointer_type.rs @@ -0,0 +1,3 @@ +type A = fn(); +type B = unsafe fn(); +type C = unsafe extern "C" fn(); diff --git a/tests/data/parser/inline/0028_fn_pointer_type.txt b/tests/data/parser/inline/0028_fn_pointer_type.txt new file mode 100644 index 000000000..6c62b0051 --- /dev/null +++ b/tests/data/parser/inline/0028_fn_pointer_type.txt @@ -0,0 +1,52 @@ +FILE@[0; 70) + TYPE_ITEM@[0; 15) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "A" + WHITESPACE@[6; 7) + EQ@[7; 8) + FN_POINTER_TYPE@[8; 13) + WHITESPACE@[8; 9) + FN_KW@[9; 11) + L_PAREN@[11; 12) + R_PAREN@[12; 13) + SEMI@[13; 14) + WHITESPACE@[14; 15) + TYPE_ITEM@[15; 37) + TYPE_KW@[15; 19) + NAME@[19; 22) + WHITESPACE@[19; 20) + IDENT@[20; 21) "B" + WHITESPACE@[21; 22) + EQ@[22; 23) + FN_POINTER_TYPE@[23; 35) + WHITESPACE@[23; 24) + UNSAFE_KW@[24; 30) + WHITESPACE@[30; 31) + FN_KW@[31; 33) + L_PAREN@[33; 34) + R_PAREN@[34; 35) + SEMI@[35; 36) + WHITESPACE@[36; 37) + TYPE_ITEM@[37; 70) + TYPE_KW@[37; 41) + NAME@[41; 44) + WHITESPACE@[41; 42) + IDENT@[42; 43) "C" + WHITESPACE@[43; 44) + EQ@[44; 45) + FN_POINTER_TYPE@[45; 68) + WHITESPACE@[45; 46) + UNSAFE_KW@[46; 52) + ABI@[52; 64) + WHITESPACE@[52; 53) + EXTERN_KW@[53; 59) + WHITESPACE@[59; 60) + STRING@[60; 63) + WHITESPACE@[63; 64) + FN_KW@[64; 66) + L_PAREN@[66; 67) + R_PAREN@[67; 68) + SEMI@[68; 69) + WHITESPACE@[69; 70) diff --git a/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.rs b/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.rs new file mode 100644 index 000000000..f014914ff --- /dev/null +++ b/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.rs @@ -0,0 +1 @@ +type F = unsafe (); 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 new file mode 100644 index 000000000..dd6e24096 --- /dev/null +++ b/tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt @@ -0,0 +1,24 @@ +FILE@[0; 20) + TYPE_ITEM@[0; 16) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "F" + WHITESPACE@[6; 7) + EQ@[7; 8) + WHITESPACE@[8; 9) + UNSAFE_KW@[9; 15) + err: `expected `fn`` + err: `expected SEMI` + WHITESPACE@[15; 16) + ERROR@[16; 17) + err: `expected item` + L_PAREN@[16; 17) + ERROR@[17; 18) + err: `expected item` + R_PAREN@[17; 18) + ERROR@[18; 20) + err: `expected item, found `;` +consider removing this semicolon` + SEMI@[18; 19) + WHITESPACE@[19; 20) diff --git a/tests/data/parser/inline/0030_fn_pointer_type_with_ret.rs b/tests/data/parser/inline/0030_fn_pointer_type_with_ret.rs new file mode 100644 index 000000000..e3ba5e87f --- /dev/null +++ b/tests/data/parser/inline/0030_fn_pointer_type_with_ret.rs @@ -0,0 +1 @@ +type F = fn() -> (); diff --git a/tests/data/parser/inline/0030_fn_pointer_type_with_ret.txt b/tests/data/parser/inline/0030_fn_pointer_type_with_ret.txt new file mode 100644 index 000000000..b41efa368 --- /dev/null +++ b/tests/data/parser/inline/0030_fn_pointer_type_with_ret.txt @@ -0,0 +1,21 @@ +FILE@[0; 21) + TYPE_ITEM@[0; 21) + TYPE_KW@[0; 4) + NAME@[4; 7) + WHITESPACE@[4; 5) + IDENT@[5; 6) "F" + WHITESPACE@[6; 7) + EQ@[7; 8) + FN_POINTER_TYPE@[8; 19) + WHITESPACE@[8; 9) + FN_KW@[9; 11) + L_PAREN@[11; 12) + R_PAREN@[12; 13) + WHITESPACE@[13; 14) + THIN_ARROW@[14; 16) + TUPLE_TYPE@[16; 19) + WHITESPACE@[16; 17) + L_PAREN@[17; 18) + R_PAREN@[18; 19) + SEMI@[19; 20) + WHITESPACE@[20; 21) -- cgit v1.2.3