mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
tests: add test for param transformation
This commit is contained in:
parent
67f7eb505e
commit
21c63abec7
1 changed files with 92 additions and 1 deletions
|
@ -517,6 +517,98 @@ mod tests {
|
|||
|
||||
use crate::tests::{check_assist, check_assist_not_applicable};
|
||||
|
||||
#[test]
|
||||
fn parameter_with_first_param_usage() {
|
||||
check_assist(
|
||||
bool_to_enum,
|
||||
r#"
|
||||
fn function($0foo: bool, bar: bool) {
|
||||
if foo {
|
||||
println!("foo");
|
||||
}
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum Bool { True, False }
|
||||
|
||||
fn function(foo: Bool, bar: bool) {
|
||||
if foo == Bool::True {
|
||||
println!("foo");
|
||||
}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parameter_with_last_param_usage() {
|
||||
check_assist(
|
||||
bool_to_enum,
|
||||
r#"
|
||||
fn function(foo: bool, $0bar: bool) {
|
||||
if bar {
|
||||
println!("bar");
|
||||
}
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum Bool { True, False }
|
||||
|
||||
fn function(foo: bool, bar: Bool) {
|
||||
if bar == Bool::True {
|
||||
println!("bar");
|
||||
}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parameter_with_middle_param_usage() {
|
||||
check_assist(
|
||||
bool_to_enum,
|
||||
r#"
|
||||
fn function(foo: bool, $0bar: bool, baz: bool) {
|
||||
if bar {
|
||||
println!("bar");
|
||||
}
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum Bool { True, False }
|
||||
|
||||
fn function(foo: bool, bar: Bool, baz: bool) {
|
||||
if bar == Bool::True {
|
||||
println!("bar");
|
||||
}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parameter_with_closure_usage() {
|
||||
check_assist(
|
||||
bool_to_enum,
|
||||
r#"
|
||||
fn main() {
|
||||
let foo = |$0bar: bool| bar;
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum Bool { True, False }
|
||||
|
||||
fn main() {
|
||||
let foo = |bar: Bool| bar == Bool::True;
|
||||
}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_variable_with_usage() {
|
||||
check_assist(
|
||||
|
@ -784,7 +876,6 @@ fn main() {
|
|||
|
||||
#[test]
|
||||
fn local_variable_non_ident_pat() {
|
||||
cov_mark::check!(not_applicable_in_non_ident_pat);
|
||||
check_assist_not_applicable(
|
||||
bool_to_enum,
|
||||
r#"
|
||||
|
|
Loading…
Reference in a new issue