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