unroll test loop

This commit is contained in:
Max Heller 2023-08-05 08:22:58 -04:00
parent 5e6d646ccc
commit d48606fefe

View File

@ -715,8 +715,8 @@ struct Foo {
#[test] #[test]
fn completes_const_and_type_generics_separately() { fn completes_const_and_type_generics_separately() {
let type_completion_cases = [ // Function generic params
// Function check(
r#" r#"
struct Foo; struct Foo;
const X: usize = 0; const X: usize = 0;
@ -725,20 +725,6 @@ fn main() {
foo::<F$0, _>(); foo::<F$0, _>();
} }
"#, "#,
// Method
r#"
const X: usize = 0;
struct Foo;
impl Foo { fn bar<const N: usize, T>(self) {} }
fn main() {
Foo.bar::<_, $0>();
}
"#,
];
for case in type_completion_cases {
check(
case,
expect![[r#" expect![[r#"
en Enum en Enum
ma makro!() macro_rules! makro ma makro!() macro_rules! makro
@ -753,9 +739,69 @@ fn main() {
kw crate:: kw crate::
kw self:: kw self::
"#]], "#]],
) );
check(
r#"
struct Foo;
const X: usize = 0;
fn foo<T, const N: usize>() {}
fn main() {
foo::<_, $0>();
} }
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Method generic params
check(
r#"
const X: usize = 0;
struct Foo;
impl Foo { fn bar<const N: usize, T>(self) {} }
fn main() {
Foo.bar::<_, $0>();
}
"#,
expect![[r#"
en Enum
ma makro!() macro_rules! makro
md module
st Foo
st Record
st Tuple
st Unit
tt Trait
un Union
bt u32
kw crate::
kw self::
"#]],
);
check(
r#"
const X: usize = 0;
struct Foo;
impl Foo { fn bar<const N: usize, T>(self) {} }
fn main() {
Foo.bar::<X$0, _>();
}
"#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Associated type generic params
check( check(
r#" r#"
const X: usize = 0; const X: usize = 0;
@ -781,27 +827,7 @@ fn foo(_: impl Bar<Baz<F$0, 0> = ()>) {}
kw self:: kw self::
"#]], "#]],
); );
check(
let const_completion_cases = [
// Function params
r#"
struct Foo;
const X: usize = 0;
fn foo<T, const N: usize>() {}
fn main() {
foo::<_, $0>();
}
"#,
// Method params
r#"
const X: usize = 0;
struct Foo;
impl Foo { fn bar<const N: usize, T>(self) {} }
fn main() {
Foo.bar::<X$0, _>();
}
"#,
// Associated type params
r#" r#"
const X: usize = 0; const X: usize = 0;
struct Foo; struct Foo;
@ -810,7 +836,17 @@ trait Bar {
} }
fn foo<T: Bar<Baz<(), $0> = ()>>() {} fn foo<T: Bar<Baz<(), $0> = ()>>() {}
"#, "#,
// Type params expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Type generic params
check(
r#" r#"
const X: usize = 0; const X: usize = 0;
struct Foo<T, const N: usize>(T); struct Foo<T, const N: usize>(T);
@ -818,7 +854,17 @@ fn main() {
let _: Foo::<_, $0> = Foo(()); let _: Foo::<_, $0> = Foo(());
} }
"#, "#,
// Enum variant params expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Type alias generic params
check(
r#" r#"
const X: usize = 0; const X: usize = 0;
struct Foo<T, const N: usize>(T); struct Foo<T, const N: usize>(T);
@ -827,6 +873,17 @@ fn main() {
let _: Bar::<X$0, _> = Bar(()); let _: Bar::<X$0, _> = Bar(());
} }
"#, "#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Enum variant params
check(
r#" r#"
const X: usize = 0; const X: usize = 0;
enum Foo<T, const N: usize> { A(T), B } enum Foo<T, const N: usize> { A(T), B }
@ -834,13 +891,33 @@ fn main() {
Foo::B::<(), $0>; Foo::B::<(), $0>;
} }
"#, "#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Trait params // Trait params
check(
r#" r#"
const X: usize = 0; const X: usize = 0;
trait Foo<T, const N: usize> {} trait Foo<T, const N: usize> {}
impl Foo<(), $0> for () {} impl Foo<(), $0> for () {}
"#, "#,
expect![[r#"
ct CONST
ct X
ma makro!() macro_rules! makro
kw crate::
kw self::
"#]],
);
// Trait alias params // Trait alias params
check(
r#" r#"
#![feature(trait_alias)] #![feature(trait_alias)]
const X: usize = 0; const X: usize = 0;
@ -848,11 +925,6 @@ trait Foo<T, const N: usize> {}
trait Bar<const M: usize, U> = Foo<U, M>; trait Bar<const M: usize, U> = Foo<U, M>;
fn foo<T: Bar<X$0, ()>>() {} fn foo<T: Bar<X$0, ()>>() {}
"#, "#,
];
for case in const_completion_cases {
check(
case,
expect![[r#" expect![[r#"
ct CONST ct CONST
ct X ct X
@ -862,4 +934,3 @@ fn foo<T: Bar<X$0, ()>>() {}
"#]], "#]],
); );
} }
}