add test for checking struct generated through macro

This commit is contained in:
dfireBird 2024-02-26 21:23:44 +05:30
parent 2ea70662f0
commit 8fa903a447
No known key found for this signature in database
GPG key ID: 26D522CA5FC2B93D

View file

@ -187,6 +187,84 @@ fn foo(bar: Bar) {
)
}
#[test]
fn fill_fields_struct_generated_by_macro() {
check_assist(
fill_record_pattern_fields,
r#"
macro_rules! position {
($t: ty) => {
struct Pos {x: $t, y: $t}
};
}
position!(usize);
fn macro_call(pos: Pos) {
let Pos { ..$0 } = pos;
}
"#,
r#"
macro_rules! position {
($t: ty) => {
struct Pos {x: $t, y: $t}
};
}
position!(usize);
fn macro_call(pos: Pos) {
let Pos { x, y } = pos;
}
"#,
);
}
#[test]
fn fill_fields_enum_generated_by_macro() {
check_assist(
fill_record_pattern_fields,
r#"
macro_rules! enum_gen {
($t: ty) => {
enum Foo {
A($t),
B{x: $t, y: $t},
}
};
}
enum_gen!(usize);
fn macro_call(foo: Foo) {
match foo {
Foo::A(_) => false,
Foo::B{ ..$0 } => true,
}
}
"#,
r#"
macro_rules! enum_gen {
($t: ty) => {
enum Foo {
A($t),
B{x: $t, y: $t},
}
};
}
enum_gen!(usize);
fn macro_call(foo: Foo) {
match foo {
Foo::A(_) => false,
Foo::B{ x, y } => true,
}
}
"#,
);
}
#[test]
fn not_applicable_when_not_in_ellipsis() {
check_assist_not_applicable(