mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
remove duplicate tests
This commit is contained in:
parent
4c8259e210
commit
c06599504b
1 changed files with 35 additions and 112 deletions
|
@ -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<T: Clone> Context<T> {
|
|||
fn data(&self) -> &T {
|
||||
&self.data
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
|
||||
check_assist(
|
||||
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_already_implemented() {
|
||||
check_not_applicable(
|
||||
check_assist_not_applicable(
|
||||
generate_getter,
|
||||
r#"
|
||||
struct Context<T: Clone> {
|
||||
dat$0a: T,
|
||||
|
@ -168,6 +184,20 @@ impl<T: Clone> Context<T> {
|
|||
fn data(&self) -> &T {
|
||||
&self.data
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
|
||||
check_assist_not_applicable(
|
||||
generate_getter_mut,
|
||||
r#"
|
||||
struct Context<T: Clone> {
|
||||
dat$0a: T,
|
||||
}
|
||||
|
||||
impl<T: Clone> Context<T> {
|
||||
fn data_mut(&mut self) -> &mut T {
|
||||
&mut self.data
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
}
|
||||
|
@ -230,110 +260,3 @@ impl<T: Clone> Context<T> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[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<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> {
|
||||
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<T: Clone> {
|
||||
dat$0a: T,
|
||||
}"#,
|
||||
r#"
|
||||
pub(crate) struct Context<T: Clone> {
|
||||
data: T,
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiple_generate_getter_mut() {
|
||||
check_assist(
|
||||
generate_getter_mut,
|
||||
r#"
|
||||
struct Context<T: Clone> {
|
||||
data: T,
|
||||
cou$0nt: usize,
|
||||
}
|
||||
|
||||
impl<T: Clone> Context<T> {
|
||||
/// Get a mutable reference to the context's data.
|
||||
fn data_mut(&mut self) -> &mut T {
|
||||
&mut self.data
|
||||
}
|
||||
}"#,
|
||||
r#"
|
||||
struct Context<T: Clone> {
|
||||
data: T,
|
||||
count: usize,
|
||||
}
|
||||
|
||||
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 mutable reference to the context's count.
|
||||
fn count_mut(&mut self) -> &mut usize {
|
||||
&mut self.count
|
||||
}
|
||||
}"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue