aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-02-11 09:58:32 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-02-11 09:58:32 +0000
commit7176029803fe2e00f29ab7d20a384e3ee6f53ba3 (patch)
tree51e7251231162d5d31b6e18fabdbb466ffb94d19 /tests
parente19d038a0e1d9af8270450c5fe8fbbdf0f15cb24 (diff)
parent96437b050f2743fef2e37eaab7259f2f98f9b473 (diff)
Merge #48
48: Types r=matklad a=matklad bors r+
Diffstat (limited to 'tests')
-rw-r--r--tests/data/parser/inline/0020_never_type.rs1
-rw-r--r--tests/data/parser/inline/0020_never_type.txt13
-rw-r--r--tests/data/parser/inline/0021_pointer_type_no_mutability.rs1
-rw-r--r--tests/data/parser/inline/0021_pointer_type_no_mutability.txt17
-rw-r--r--tests/data/parser/inline/0022_pointer_type_mut.rs2
-rw-r--r--tests/data/parser/inline/0022_pointer_type_mut.txt35
-rw-r--r--tests/data/parser/inline/0023_array_type_missing_semi.rs1
-rw-r--r--tests/data/parser/inline/0023_array_type_missing_semi.txt28
-rw-r--r--tests/data/parser/inline/0024_array_type.rs1
-rw-r--r--tests/data/parser/inline/0024_array_type.txt21
-rw-r--r--tests/data/parser/inline/0025_slice_type.rs1
-rw-r--r--tests/data/parser/inline/0025_slice_type.txt17
-rw-r--r--tests/data/parser/inline/0026_reference_type;.rs3
-rw-r--r--tests/data/parser/inline/0026_reference_type;.txt50
-rw-r--r--tests/data/parser/inline/0027_placeholder_type.rs1
-rw-r--r--tests/data/parser/inline/0027_placeholder_type.txt13
-rw-r--r--tests/data/parser/inline/0028_fn_pointer_type.rs3
-rw-r--r--tests/data/parser/inline/0028_fn_pointer_type.txt52
-rw-r--r--tests/data/parser/inline/0029_fn_pointer_type_missing_fn.rs1
-rw-r--r--tests/data/parser/inline/0029_fn_pointer_type_missing_fn.txt24
-rw-r--r--tests/data/parser/inline/0030_fn_pointer_type_with_ret.rs1
-rw-r--r--tests/data/parser/inline/0030_fn_pointer_type_with_ret.txt21
-rw-r--r--tests/testutils/src/lib.rs15
23 files changed, 314 insertions, 8 deletions
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 @@
1FILE@[0; 16)
2 TYPE_ITEM@[0; 16)
3 TYPE_KW@[0; 4)
4 NAME@[4; 11)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 10) "Never"
7 WHITESPACE@[10; 11)
8 EQ@[11; 12)
9 NEVER_TYPE@[12; 14)
10 WHITESPACE@[12; 13)
11 EXCL@[13; 14)
12 SEMI@[14; 15)
13 WHITESPACE@[15; 16)
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 @@
1FILE@[0; 14)
2 TYPE_ITEM@[0; 14)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "T"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 POINTER_TYPE@[8; 12)
10 WHITESPACE@[8; 9)
11 STAR@[9; 10)
12 err: `expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)`
13 TUPLE_TYPE@[10; 12)
14 L_PAREN@[10; 11)
15 R_PAREN@[11; 12)
16 SEMI@[12; 13)
17 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 @@
1type M = *mut ();
2type 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 @@
1FILE@[0; 36)
2 TYPE_ITEM@[0; 18)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "M"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 POINTER_TYPE@[8; 16)
10 WHITESPACE@[8; 9)
11 STAR@[9; 10)
12 MUT_KW@[10; 13)
13 TUPLE_TYPE@[13; 16)
14 WHITESPACE@[13; 14)
15 L_PAREN@[14; 15)
16 R_PAREN@[15; 16)
17 SEMI@[16; 17)
18 WHITESPACE@[17; 18)
19 TYPE_ITEM@[18; 36)
20 TYPE_KW@[18; 22)
21 NAME@[22; 25)
22 WHITESPACE@[22; 23)
23 IDENT@[23; 24) "C"
24 WHITESPACE@[24; 25)
25 EQ@[25; 26)
26 POINTER_TYPE@[26; 34)
27 WHITESPACE@[26; 27)
28 STAR@[27; 28)
29 MUT_KW@[28; 31)
30 TUPLE_TYPE@[31; 34)
31 WHITESPACE@[31; 32)
32 L_PAREN@[32; 33)
33 R_PAREN@[33; 34)
34 SEMI@[34; 35)
35 WHITESPACE@[35; 36)
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 @@
1FILE@[0; 18)
2 TYPE_ITEM@[0; 13)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "T"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 SLICE_TYPE@[8; 13)
10 WHITESPACE@[8; 9)
11 L_BRACK@[9; 10)
12 TUPLE_TYPE@[10; 13)
13 L_PAREN@[10; 11)
14 R_PAREN@[11; 12)
15 WHITESPACE@[12; 13)
16 err: `expected `;` or `]``
17 err: `expected SEMI`
18 ERROR@[13; 15)
19 err: `expected item`
20 INT_NUMBER@[13; 15)
21 ERROR@[15; 16)
22 err: `expected item`
23 R_BRACK@[15; 16)
24 ERROR@[16; 18)
25 err: `expected item, found `;`
26consider removing this semicolon`
27 SEMI@[16; 17)
28 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 @@
1FILE@[0; 19)
2 TYPE_ITEM@[0; 19)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "T"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 ARRAY_TYPE@[8; 17)
10 WHITESPACE@[8; 9)
11 L_BRACK@[9; 10)
12 TUPLE_TYPE@[10; 12)
13 L_PAREN@[10; 11)
14 R_PAREN@[11; 12)
15 SEMI@[12; 13)
16 LITERAL@[13; 16)
17 WHITESPACE@[13; 14)
18 INT_NUMBER@[14; 16)
19 R_BRACK@[16; 17)
20 SEMI@[17; 18)
21 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 @@
1FILE@[0; 15)
2 TYPE_ITEM@[0; 15)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "T"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 SLICE_TYPE@[8; 13)
10 WHITESPACE@[8; 9)
11 L_BRACK@[9; 10)
12 TUPLE_TYPE@[10; 12)
13 L_PAREN@[10; 11)
14 R_PAREN@[11; 12)
15 R_BRACK@[12; 13)
16 SEMI@[13; 14)
17 WHITESPACE@[14; 15)
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 @@
1type A = &();
2type B = &'static ();
3type 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 @@
1FILE@[0; 54)
2 TYPE_ITEM@[0; 14)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "A"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 REFERENCE_TYPE@[8; 12)
10 WHITESPACE@[8; 9)
11 AMPERSAND@[9; 10)
12 TUPLE_TYPE@[10; 12)
13 L_PAREN@[10; 11)
14 R_PAREN@[11; 12)
15 SEMI@[12; 13)
16 WHITESPACE@[13; 14)
17 TYPE_ITEM@[14; 36)
18 TYPE_KW@[14; 18)
19 NAME@[18; 21)
20 WHITESPACE@[18; 19)
21 IDENT@[19; 20) "B"
22 WHITESPACE@[20; 21)
23 EQ@[21; 22)
24 REFERENCE_TYPE@[22; 34)
25 WHITESPACE@[22; 23)
26 AMPERSAND@[23; 24)
27 LIFETIME@[24; 31) "'static"
28 TUPLE_TYPE@[31; 34)
29 WHITESPACE@[31; 32)
30 L_PAREN@[32; 33)
31 R_PAREN@[33; 34)
32 SEMI@[34; 35)
33 WHITESPACE@[35; 36)
34 TYPE_ITEM@[36; 54)
35 TYPE_KW@[36; 40)
36 NAME@[40; 43)
37 WHITESPACE@[40; 41)
38 IDENT@[41; 42) "C"
39 WHITESPACE@[42; 43)
40 EQ@[43; 44)
41 REFERENCE_TYPE@[44; 52)
42 WHITESPACE@[44; 45)
43 AMPERSAND@[45; 46)
44 MUT_KW@[46; 49)
45 TUPLE_TYPE@[49; 52)
46 WHITESPACE@[49; 50)
47 L_PAREN@[50; 51)
48 R_PAREN@[51; 52)
49 SEMI@[52; 53)
50 WHITESPACE@[53; 54)
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 @@
1FILE@[0; 22)
2 TYPE_ITEM@[0; 22)
3 TYPE_KW@[0; 4)
4 NAME@[4; 17)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 16) "Placeholder"
7 WHITESPACE@[16; 17)
8 EQ@[17; 18)
9 PLACEHOLDER_TYPE@[18; 20)
10 WHITESPACE@[18; 19)
11 UNDERSCORE@[19; 20)
12 SEMI@[20; 21)
13 WHITESPACE@[21; 22)
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 @@
1type A = fn();
2type B = unsafe fn();
3type 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 @@
1FILE@[0; 70)
2 TYPE_ITEM@[0; 15)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "A"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 FN_POINTER_TYPE@[8; 13)
10 WHITESPACE@[8; 9)
11 FN_KW@[9; 11)
12 L_PAREN@[11; 12)
13 R_PAREN@[12; 13)
14 SEMI@[13; 14)
15 WHITESPACE@[14; 15)
16 TYPE_ITEM@[15; 37)
17 TYPE_KW@[15; 19)
18 NAME@[19; 22)
19 WHITESPACE@[19; 20)
20 IDENT@[20; 21) "B"
21 WHITESPACE@[21; 22)
22 EQ@[22; 23)
23 FN_POINTER_TYPE@[23; 35)
24 WHITESPACE@[23; 24)
25 UNSAFE_KW@[24; 30)
26 WHITESPACE@[30; 31)
27 FN_KW@[31; 33)
28 L_PAREN@[33; 34)
29 R_PAREN@[34; 35)
30 SEMI@[35; 36)
31 WHITESPACE@[36; 37)
32 TYPE_ITEM@[37; 70)
33 TYPE_KW@[37; 41)
34 NAME@[41; 44)
35 WHITESPACE@[41; 42)
36 IDENT@[42; 43) "C"
37 WHITESPACE@[43; 44)
38 EQ@[44; 45)
39 FN_POINTER_TYPE@[45; 68)
40 WHITESPACE@[45; 46)
41 UNSAFE_KW@[46; 52)
42 ABI@[52; 64)
43 WHITESPACE@[52; 53)
44 EXTERN_KW@[53; 59)
45 WHITESPACE@[59; 60)
46 STRING@[60; 63)
47 WHITESPACE@[63; 64)
48 FN_KW@[64; 66)
49 L_PAREN@[66; 67)
50 R_PAREN@[67; 68)
51 SEMI@[68; 69)
52 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 @@
1FILE@[0; 20)
2 TYPE_ITEM@[0; 16)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "F"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 WHITESPACE@[8; 9)
10 UNSAFE_KW@[9; 15)
11 err: `expected `fn``
12 err: `expected SEMI`
13 WHITESPACE@[15; 16)
14 ERROR@[16; 17)
15 err: `expected item`
16 L_PAREN@[16; 17)
17 ERROR@[17; 18)
18 err: `expected item`
19 R_PAREN@[17; 18)
20 ERROR@[18; 20)
21 err: `expected item, found `;`
22consider removing this semicolon`
23 SEMI@[18; 19)
24 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 @@
1FILE@[0; 21)
2 TYPE_ITEM@[0; 21)
3 TYPE_KW@[0; 4)
4 NAME@[4; 7)
5 WHITESPACE@[4; 5)
6 IDENT@[5; 6) "F"
7 WHITESPACE@[6; 7)
8 EQ@[7; 8)
9 FN_POINTER_TYPE@[8; 19)
10 WHITESPACE@[8; 9)
11 FN_KW@[9; 11)
12 L_PAREN@[11; 12)
13 R_PAREN@[12; 13)
14 WHITESPACE@[13; 14)
15 THIN_ARROW@[14; 16)
16 TUPLE_TYPE@[16; 19)
17 WHITESPACE@[16; 17)
18 L_PAREN@[17; 18)
19 R_PAREN@[18; 19)
20 SEMI@[19; 20)
21 WHITESPACE@[20; 21)
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
26 F: Fn(&str) -> String, 26 F: Fn(&str) -> String,
27{ 27{
28 for path in collect_tests(paths) { 28 for path in collect_tests(paths) {
29 let actual = { 29 let input_code = read_text(&path);
30 let text = read_text(&path); 30 let parse_tree = f(&input_code);
31 f(&text)
32 };
33 let path = path.with_extension("txt"); 31 let path = path.with_extension("txt");
34 if !path.exists() { 32 if !path.exists() {
35 println!("\nfile: {}", path.display()); 33 println!("\nfile: {}", path.display());
36 println!("No .txt file with expected result, creating..."); 34 println!("No .txt file with expected result, creating...\n");
37 file::put_text(&path, actual).unwrap(); 35 println!("{}\n{}", input_code, parse_tree);
36 file::put_text(&path, parse_tree).unwrap();
38 panic!("No expected result") 37 panic!("No expected result")
39 } 38 }
40 let expected = read_text(&path); 39 let expected = read_text(&path);
41 let expected = expected.as_str(); 40 let expected = expected.as_str();
42 let actual = actual.as_str(); 41 let parse_tree = parse_tree.as_str();
43 assert_equal_text(expected, actual, &path); 42 assert_equal_text(expected, parse_tree, &path);
44 } 43 }
45} 44}
46 45