Skip to content

Commit

Permalink
Add cov_mark tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vsrs committed Aug 28, 2023
1 parent e457759 commit 19e9994
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion crates/ide-assists/src/handlers/bind_unused_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
let right_line = line_index.line_col(r_curly_range.start()).line;

if left_line == right_line {
cov_mark::hit!(single_line);
text.push('\n');
}

Expand All @@ -75,12 +76,13 @@ pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> O

#[cfg(test)]
mod tests {
use crate::tests::check_assist;
use crate::tests::{check_assist, check_assist_not_applicable};

use super::*;

#[test]
fn bind_unused_empty_block() {
cov_mark::check!(single_line);
check_assist(
bind_unused_param,
r#"
Expand Down Expand Up @@ -124,6 +126,33 @@ fn foo<T>(y: T)
where T : Default {
let _ = y;
}
"#,
);
}

#[test]
fn trait_impl() {
cov_mark::check!(trait_impl);
check_assist_not_applicable(
bind_unused_param,
r#"
trait Trait {
fn foo(x: i32);
}
impl Trait for () {
fn foo($0x: i32) {}
}
"#,
);
}

#[test]
fn keep_used() {
cov_mark::check!(keep_used);
check_assist_not_applicable(
bind_unused_param,
r#"
fn foo(x: i32, $0y: i32) { y; }
"#,
);
}
Expand Down

0 comments on commit 19e9994

Please sign in to comment.