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 | 129 ++++-------------- 1 file changed, 26 insertions(+), 103 deletions(-) diff --git a/crates/ide_assists/src/handlers/generate_getter.rs b/crates/ide_assists/src/handlers/generate_getter.rs index e01985112d3..fbd47d76111 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( @@ -154,121 +150,48 @@ fn data(&self) -> &T { } }"#, ); - } - - #[test] - fn test_generate_getter_already_implemented() { - check_not_applicable( - r#" -struct Context { - dat$0a: T, -} - -impl Context { - fn data(&self) -> &T { - &self.data - } -}"#, - ); - } - #[test] - fn test_generate_getter_from_field_with_visibility_marker() { check_assist( - generate_getter, + generate_getter_mut, r#" -pub(crate) struct Context { +struct Context { dat$0a: T, }"#, r#" -pub(crate) struct Context { +struct Context { data: T, } impl Context { - /// Get a reference to the context's data. - pub(crate) fn data(&self) -> &T { - &self.data + /// Get a mutable reference to the context's data. + fn data_mut(&mut self) -> &mut T { + &mut self.data } }"#, ); } #[test] - fn test_multiple_generate_getter() { - check_assist( + fn test_generate_getter_already_implemented() { + check_assist_not_applicable( generate_getter, r#" struct Context { - data: T, - cou$0nt: usize, -} - -impl Context { - /// Get a reference to the context's data. - fn data(&self) -> &T { - &self.data - } -}"#, - r#" -struct Context { - data: T, - count: usize, + dat$0a: T, } impl Context { - /// Get a reference to the context's data. fn data(&self) -> &T { &self.data } - - /// Get a reference to the context's count. - fn count(&self) -> &usize { - &self.count - } }"#, ); - } -} - -#[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( + check_assist_not_applicable( 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 { @@ -280,9 +203,9 @@ fn data_mut(&mut self) -> &mut T { } #[test] - fn test_generate_getter_mut_from_field_with_visibility_marker() { + fn test_generate_getter_from_field_with_visibility_marker() { check_assist( - generate_getter_mut, + generate_getter, r#" pub(crate) struct Context { dat$0a: T, @@ -293,18 +216,18 @@ pub(crate) struct Context { } impl Context { - /// Get a mutable reference to the context's data. - pub(crate) fn data_mut(&mut self) -> &mut T { - &mut self.data + /// Get a reference to the context's data. + pub(crate) fn data(&self) -> &T { + &self.data } }"#, ); } #[test] - fn test_multiple_generate_getter_mut() { + fn test_multiple_generate_getter() { check_assist( - generate_getter_mut, + generate_getter, r#" struct Context { data: T, @@ -312,9 +235,9 @@ struct Context { } impl Context { - /// Get a mutable reference to the context's data. - fn data_mut(&mut self) -> &mut T { - &mut self.data + /// Get a reference to the context's data. + fn data(&self) -> &T { + &self.data } }"#, r#" @@ -324,14 +247,14 @@ struct Context { } impl Context { - /// Get a mutable reference to the context's data. - fn data_mut(&mut self) -> &mut T { - &mut self.data + /// Get a reference to the context's data. + fn data(&self) -> &T { + &self.data } - /// Get a mutable reference to the context's count. - fn count_mut(&mut self) -> &mut usize { - &mut self.count + /// Get a reference to the context's count. + fn count(&self) -> &usize { + &self.count } }"#, ); -- 2.44.0