Skip to content

Commit 6731a9f

Browse files
committed
Add tests for type role errors
1 parent c51d450 commit 6731a9f

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

crates/indexing/tests/indexing.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ fn duplicate_expr_item() {
8787
"foreign import eq :: forall a. a -> a -> Bool",
8888
"instance ord :: Ord a",
8989
"ord :: forall a. a -> a -> Comparison",
90+
"ord = ordImpl",
9091
"data Data = Id Int",
9192
"newtype Newtype = Id Int",
9293
]);
@@ -103,7 +104,9 @@ fn duplicate_type_item() {
103104
"type Data = Type",
104105
"newtype Newtype = Constructor2",
105106
"data Newtype = Constructor3",
106-
"data Newtype :: Type"
107+
"data Newtype :: Type",
108+
"data Id = Constructor4",
109+
"data Id = Constructor5"
107110
]);
108111
insta::assert_debug_snapshot!(errors);
109112
}
@@ -169,3 +172,16 @@ fn type_late_signature() {
169172
]);
170173
insta::assert_debug_snapshot!(errors);
171174
}
175+
176+
#[test]
177+
fn type_role_errors() {
178+
let (_, _, errors) = index([
179+
"class Eq a",
180+
"type role Eq representational",
181+
"type role Ord representational",
182+
"newtype Id :: Type -> Type",
183+
"type role Id nominal",
184+
"type role Id phantom",
185+
]);
186+
insta::assert_debug_snapshot!(errors);
187+
}

crates/indexing/tests/snapshots/indexing__duplicate_expr_item.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
source: crates/indexing/tests/indexing.rs
33
expression: errors
4+
snapshot_kind: text
45
---
56
[
67
DuplicateExprItem {
@@ -43,6 +44,16 @@ expression: errors
4344
),
4445
),
4546
},
47+
DuplicateExprItem {
48+
item_id: Id(
49+
1,
50+
),
51+
duplicate: Declaration(
52+
Id(
53+
6,
54+
),
55+
),
56+
},
4657
DuplicateExprItem {
4758
item_id: Id(
4859
2,

crates/indexing/tests/snapshots/indexing__duplicate_type_item.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
source: crates/indexing/tests/indexing.rs
33
expression: errors
4+
snapshot_kind: text
45
---
56
[
67
DuplicateTypeItem {
@@ -63,4 +64,12 @@ expression: errors
6364
),
6465
),
6566
},
67+
DuplicateDeclaration {
68+
declaration: Id(
69+
8,
70+
),
71+
duplicate: Id(
72+
9,
73+
),
74+
},
6675
]
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
source: crates/indexing/tests/indexing.rs
3+
expression: errors
4+
snapshot_kind: text
5+
---
6+
[
7+
InvalidRole {
8+
role: Id(
9+
1,
10+
),
11+
},
12+
EmptyRole {
13+
role: Id(
14+
2,
15+
),
16+
},
17+
EmptyRole {
18+
role: Id(
19+
4,
20+
),
21+
},
22+
EmptyRole {
23+
role: Id(
24+
5,
25+
),
26+
},
27+
DuplicateDeclaration {
28+
declaration: Id(
29+
4,
30+
),
31+
duplicate: Id(
32+
5,
33+
),
34+
},
35+
]

0 commit comments

Comments
 (0)