Skip to content

Commit

Permalink
add test case for robustness against accidental selections in `merge_…
Browse files Browse the repository at this point in the history
…match_arms`
  • Loading branch information
cmrschwarz committed Nov 18, 2024
1 parent 0b58bde commit ffbf9b6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions crates/ide-assists/src/handlers/merge_match_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,36 @@ fn main() {
);
}

#[test]
fn merge_match_arms_works_despite_accidental_selection() {
check_assist(
merge_match_arms,
r#"
#[derive(Debug)]
enum X { A, B, C }
fn main() {
match X::A {
X::$0A$0 => 0,
X::B => 0,
X::C => 1,
}
}
"#,
r#"
#[derive(Debug)]
enum X { A, B, C }
fn main() {
match X::A {
X::A | X::B => 0,
X::C => 1,
}
}
"#,
);
}

#[test]
fn merge_match_arms_rejects_guards() {
check_assist_not_applicable(
Expand Down

0 comments on commit ffbf9b6

Please sign in to comment.