From d338a803941c2b0ac83decfcdfac33c09dfaa971 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 16 Jun 2021 17:37:23 +0200 Subject: Start refactoring ide_completion tests --- crates/ide_completion/src/tests/item_list.rs | 172 +++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 crates/ide_completion/src/tests/item_list.rs (limited to 'crates/ide_completion/src/tests') diff --git a/crates/ide_completion/src/tests/item_list.rs b/crates/ide_completion/src/tests/item_list.rs new file mode 100644 index 000000000..bd060a632 --- /dev/null +++ b/crates/ide_completion/src/tests/item_list.rs @@ -0,0 +1,172 @@ +use expect_test::expect; + +use crate::tests::check; + +#[test] +fn in_mod_item_list() { + check( + r#"mod tests { + $0 +} +"#, + expect![[r#" + kw pub(crate) + kw pub + kw unsafe + kw fn + kw const + kw type + kw use + kw impl + kw trait + kw static + kw extern + kw mod + kw enum + kw struct + kw union + sn tmod (Test module) + sn tfn (Test function) + sn macro_rules + "#]], + ) +} + +#[test] +fn in_source_file_item_list() { + check( + r#" +enum Enum { Variant } +struct MyStruct {} +#[macro_export] +macro_rules! foo {} +mod bar {} +const CONST: () = (); + +$0"#, + expect![[r##" + kw pub(crate) + kw pub + kw unsafe + kw fn + kw const + kw type + kw use + kw impl + kw trait + kw static + kw extern + kw mod + kw enum + kw struct + kw union + sn tmod (Test module) + sn tfn (Test function) + sn macro_rules + md bar + ma foo!(…) #[macro_export] macro_rules! foo + ma foo!(…) #[macro_export] macro_rules! foo + "##]], + ) +} + +#[test] +fn in_qualified_path() { + check( + r#" +enum Enum { Variant } +struct MyStruct {} +#[macro_export] +macro_rules! foo {} +mod bar {} +const CONST: () = (); + +crate::$0"#, + expect![[r##" + kw pub(crate) + kw pub + kw unsafe + kw fn + kw const + kw type + kw use + kw impl + kw trait + kw static + kw extern + kw mod + kw enum + kw struct + kw union + sn tmod (Test module) + sn tfn (Test function) + sn macro_rules + md bar + ma foo!(…) #[macro_export] macro_rules! foo + "##]], + ) +} + +#[test] +fn after_unsafe_token() { + check( + r#" +enum Enum { Variant } +struct MyStruct {} +#[macro_export] +macro_rules! foo {} +mod bar {} +const CONST: () = (); + +unsafe $0"#, + expect![[r##" + kw fn + kw trait + kw impl + sn tmod (Test module) + sn tfn (Test function) + sn macro_rules + md bar + ma foo!(…) #[macro_export] macro_rules! foo + ma foo!(…) #[macro_export] macro_rules! foo + "##]], + ); +} + +#[test] +fn after_visibility() { + check( + r#" +enum Enum { Variant } +struct MyStruct {} +#[macro_export] +macro_rules! foo {} +mod bar {} +const CONST: () = (); + +pub $0"#, + expect![[r##" + kw pub(crate) + kw pub + kw unsafe + kw fn + kw const + kw type + kw use + kw impl + kw trait + kw static + kw extern + kw mod + kw enum + kw struct + kw union + sn tmod (Test module) + sn tfn (Test function) + sn macro_rules + md bar + ma foo!(…) #[macro_export] macro_rules! foo + ma foo!(…) #[macro_export] macro_rules! foo + "##]], + ); +} -- cgit v1.2.3