Skip to content

Commit 390b171

Browse files
committed
Add test for duplicate item in crate
1 parent b442a43 commit 390b171

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/test/mod.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,61 @@ fn trait_items_with_duplicate_associated_type_names() {
215215
the associated type name `Assoc` is defined multiple times"#]]
216216
);
217217
}
218+
219+
#[test]
220+
fn crate_with_duplicate_item_names() {
221+
crate::assert_err!(
222+
[
223+
crate core {
224+
struct A {}
225+
226+
enum A {}
227+
}
228+
]
229+
230+
["the item name `A` is defined multiple times",]
231+
232+
expect_test::expect![[r#"the item name `A` is defined multiple times"#]]
233+
);
234+
235+
crate::assert_err!(
236+
[
237+
crate core {
238+
trait a {}
239+
240+
trait a {}
241+
}
242+
]
243+
244+
["the trait name `a` is defined multiple times",]
245+
246+
expect_test::expect![[r#"the trait name `a` is defined multiple times"#]]
247+
);
248+
249+
crate::assert_err!(
250+
[
251+
crate core {
252+
fn a() -> () { trusted }
253+
254+
fn a() -> () { trusted }
255+
}
256+
]
257+
258+
["the function name `a` is defined multiple times",]
259+
260+
expect_test::expect![[r#"the function name `a` is defined multiple times"#]]
261+
);
262+
263+
crate::assert_ok!(
264+
//@check-pass
265+
[
266+
crate core {
267+
trait a {}
268+
269+
fn a() -> () { trusted }
270+
}
271+
]
272+
273+
expect_test::expect!["()"]
274+
);
275+
}

0 commit comments

Comments
 (0)