]> git.lizzy.rs Git - rust.git/commitdiff
remove duplicate tests
authorAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 23 May 2021 20:15:54 +0000 (23:15 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Sun, 23 May 2021 20:15:54 +0000 (23:15 +0300)
crates/ide_assists/src/handlers/generate_getter.rs

index e01985112d3f73857d36fc609eb4f90193dba065..fbd47d76111d4c7a96c42f0bbbeadf340e1ae40d 100644 (file)
@@ -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<T: Clone> {
-    dat$0a: T,
-}
-
-impl<T: Clone> Context<T> {
-    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<T: Clone> {
+struct Context<T: Clone> {
     dat$0a: T,
 }"#,
             r#"
-pub(crate) struct Context<T: Clone> {
+struct Context<T: Clone> {
     data: T,
 }
 
 impl<T: Clone> Context<T> {
-    /// 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<T: Clone> {
-    data: T,
-    cou$0nt: usize,
-}
-
-impl<T: Clone> Context<T> {
-    /// Get a reference to the context's data.
-    fn data(&self) -> &T {
-        &self.data
-    }
-}"#,
-            r#"
-struct Context<T: Clone> {
-    data: T,
-    count: usize,
+    dat$0a: T,
 }
 
 impl<T: Clone> Context<T> {
-    /// 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<T: Clone> {
     dat$0a: T,
-}"#,
-            r#"
-struct Context<T: Clone> {
-    data: T,
-}
-
-impl<T: Clone> Context<T> {
-    /// 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<T: Clone> {
-    dat$0a: T,
 }
 
 impl<T: Clone> Context<T> {
@@ -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<T: Clone> {
     dat$0a: T,
@@ -293,18 +216,18 @@ pub(crate) struct Context<T: Clone> {
 }
 
 impl<T: Clone> Context<T> {
-    /// 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<T: Clone> {
     data: T,
@@ -312,9 +235,9 @@ struct Context<T: Clone> {
 }
 
 impl<T: Clone> Context<T> {
-    /// 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<T: Clone> {
 }
 
 impl<T: Clone> Context<T> {
-    /// 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
     }
 }"#,
         );