test cases with more branches

This commit is contained in:
Jeroen Vannevel 2022-01-10 18:46:47 +00:00
parent 130f11f270
commit 5675e0cd40
No known key found for this signature in database
GPG Key ID: 78EF5F52F38C49BD

View File

@ -325,6 +325,64 @@ fn func() {
Ok(x) | Err(x) => x.1.classify(),
};
}
"#,
);
}
#[test]
fn merge_match_arms_same_type_subsequent_arm_with_different_type_in_other() {
check_assist(
merge_match_arms,
r#"
enum MyEnum {
OptionA(f32),
OptionB(f32),
OptionC(f64)
}
fn func(e: MyEnum) {
match e {
MyEnum::OptionA(x) => $0x.classify(),
MyEnum::OptionB(x) => x.classify(),
MyEnum::OptionC(x) => x.classify(),
};
}
"#,
r#"
enum MyEnum {
OptionA(f32),
OptionB(f32),
OptionC(f64)
}
fn func(e: MyEnum) {
match e {
MyEnum::OptionA(x) | MyEnum::OptionB(x) => x.classify(),
MyEnum::OptionC(x) => x.classify(),
};
}
"#,
);
}
#[test]
fn merge_match_arms_same_type_skip_arm_with_different_type_in_between() {
check_assist_not_applicable(
merge_match_arms,
r#"
enum MyEnum {
OptionA(f32),
OptionB(f64),
OptionC(f32)
}
fn func(e: MyEnum) {
match e {
MyEnum::OptionA(x) => $0x.classify(),
MyEnum::OptionB(x) => x.classify(),
MyEnum::OptionC(x) => x.classify(),
};
}
"#,
);
}