From c06599504bc4fcbb3d5024d9a8bdb14f263bad36 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 23 May 2021 23:15:54 +0300 Subject: [PATCH] remove duplicate tests --- .../src/handlers/generate_getter.rs | 147 +++++------------- 1 file changed, 35 insertions(+), 112 deletions(-) diff --git a/crates/ide_assists/src/handlers/generate_getter.rs b/crates/ide_assists/src/handlers/generate_getter.rs index e01985112d..fbd47d7611 100644 --- a/crates/ide_assists/src/handlers/generate_getter.rs +++ b/crates/ide_assists/src/handlers/generate_getter.rs @@ -130,10 +130,6 @@ mod tests { use super::*; - fn check_not_applicable(ra_fixture: &str) { - check_assist_not_applicable(generate_getter, ra_fixture) - } - #[test] fn test_generate_getter_from_field() { check_assist( @@ -152,13 +148,33 @@ impl Context { fn data(&self) -> &T { &self.data } +}"#, + ); + + check_assist( + generate_getter_mut, + r#" +struct Context { + dat$0a: T, +}"#, + r#" +struct Context { + data: T, +} + +impl Context { + /// Get a mutable reference to the context's data. + fn data_mut(&mut self) -> &mut T { + &mut self.data + } }"#, ); } #[test] fn test_generate_getter_already_implemented() { - check_not_applicable( + check_assist_not_applicable( + generate_getter, r#" struct Context { dat$0a: T, @@ -168,6 +184,20 @@ impl Context { fn data(&self) -> &T { &self.data } +}"#, + ); + + check_assist_not_applicable( + generate_getter_mut, + r#" +struct Context { + dat$0a: T, +} + +impl Context { + fn data_mut(&mut self) -> &mut T { + &mut self.data + } }"#, ); } @@ -230,110 +260,3 @@ impl Context { ); } } - -#[cfg(test)] -mod tests_mut { - use crate::tests::{check_assist, check_assist_not_applicable}; - - use super::*; - - fn check_not_applicable(ra_fixture: &str) { - check_assist_not_applicable(generate_getter_mut, ra_fixture) - } - - #[test] - fn test_generate_getter_mut_from_field() { - check_assist( - generate_getter_mut, - r#" -struct Context { - dat$0a: T, -}"#, - r#" -struct Context { - data: T, -} - -impl Context { - /// Get a mutable reference to the context's data. - fn data_mut(&mut self) -> &mut T { - &mut self.data - } -}"#, - ); - } - - #[test] - fn test_generate_getter_mut_already_implemented() { - check_not_applicable( - r#" -struct Context { - dat$0a: T, -} - -impl Context { - fn data_mut(&mut self) -> &mut T { - &mut self.data - } -}"#, - ); - } - - #[test] - fn test_generate_getter_mut_from_field_with_visibility_marker() { - check_assist( - generate_getter_mut, - r#" -pub(crate) struct Context { - dat$0a: T, -}"#, - r#" -pub(crate) struct Context { - data: T, -} - -impl Context { - /// Get a mutable reference to the context's data. - pub(crate) fn data_mut(&mut self) -> &mut T { - &mut self.data - } -}"#, - ); - } - - #[test] - fn test_multiple_generate_getter_mut() { - check_assist( - generate_getter_mut, - r#" -struct Context { - data: T, - cou$0nt: usize, -} - -impl Context { - /// Get a mutable reference to the context's data. - fn data_mut(&mut self) -> &mut T { - &mut self.data - } -}"#, - r#" -struct Context { - data: T, - count: usize, -} - -impl Context { - /// Get a mutable reference to the context's data. - fn data_mut(&mut self) -> &mut T { - &mut self.data - } - - /// Get a mutable reference to the context's count. - fn count_mut(&mut self) -> &mut usize { - &mut self.count - } -}"#, - ); - } -}