From 8f936c557162d66a451f10481ff726a37b27302e Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 16 Jun 2021 19:25:09 +0200 Subject: Add builtin derives to attribute completion fixtures --- .../src/completions/attribute/derive.rs | 74 ++++++++++++++++++++-- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/crates/ide_completion/src/completions/attribute/derive.rs b/crates/ide_completion/src/completions/attribute/derive.rs index 7b3133e53..c59add6c5 100644 --- a/crates/ide_completion/src/completions/attribute/derive.rs +++ b/crates/ide_completion/src/completions/attribute/derive.rs @@ -83,7 +83,31 @@ mod tests { use crate::{test_utils::completion_list, CompletionKind}; fn check(ra_fixture: &str, expect: Expect) { - let actual = completion_list(ra_fixture, CompletionKind::Attribute); + let builtin_derives = r#" +#[rustc_builtin_macro] +pub macro Clone {} +#[rustc_builtin_macro] +pub macro Copy {} +#[rustc_builtin_macro] +pub macro Default {} +#[rustc_builtin_macro] +pub macro Debug {} +#[rustc_builtin_macro] +pub macro Hash {} +#[rustc_builtin_macro] +pub macro PartialEq {} +#[rustc_builtin_macro] +pub macro Eq {} +#[rustc_builtin_macro] +pub macro PartialOrd {} +#[rustc_builtin_macro] +pub macro Ord {} + +"#; + let actual = completion_list( + &format!("{} {}", builtin_derives, ra_fixture), + CompletionKind::Attribute, + ); expect.assert_eq(&actual); } @@ -94,19 +118,55 @@ mod tests { #[test] fn empty_derive() { - // FIXME: Add build-in derives to fixture. - check(r#"#[derive($0)] struct Test;"#, expect![[r#""#]]); + check( + r#"#[derive($0)] struct Test;"#, + expect![[r#" + at PartialEq + at Default + at PartialEq, Eq + at PartialEq, Eq, PartialOrd, Ord + at Clone, Copy + at Debug + at Clone + at Hash + at PartialEq, PartialOrd + "#]], + ); } #[test] fn derive_with_input() { - // FIXME: Add build-in derives to fixture. - check(r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, expect![[r#""#]]) + check( + r#"#[derive(serde::Serialize, PartialEq, $0)] struct Test;"#, + expect![[r#" + at PartialEq + at Default + at Eq + at Eq, PartialOrd, Ord + at Clone, Copy + at Debug + at Clone + at Hash + at PartialOrd + "#]], + ) } #[test] fn derive_with_input2() { - // FIXME: Add build-in derives to fixture. - check(r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, expect![[r#""#]]) + check( + r#"#[derive($0 serde::Serialize, PartialEq)] struct Test;"#, + expect![[r#" + at PartialEq + at Default + at Eq + at Eq, PartialOrd, Ord + at Clone, Copy + at Debug + at Clone + at Hash + at PartialOrd + "#]], + ) } } -- cgit v1.2.3