mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Move out completion type position tests
This commit is contained in:
parent
f835279b3a
commit
b9d85f55b7
5 changed files with 198 additions and 206 deletions
|
@ -35,22 +35,6 @@ impl Tra$0
|
|||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
bt u32
|
||||
bt bool
|
||||
bt u8
|
||||
bt isize
|
||||
bt u16
|
||||
bt u64
|
||||
bt u128
|
||||
bt f32
|
||||
bt i128
|
||||
bt i16
|
||||
bt str
|
||||
bt i64
|
||||
bt char
|
||||
bt f64
|
||||
bt i32
|
||||
bt i8
|
||||
bt usize
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
@ -69,22 +53,6 @@ impl Trait for Str$0
|
|||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
ma foo!(…) #[macro_export] macro_rules! foo
|
||||
bt u32
|
||||
bt bool
|
||||
bt u8
|
||||
bt isize
|
||||
bt u16
|
||||
bt u64
|
||||
bt u128
|
||||
bt f32
|
||||
bt i128
|
||||
bt i16
|
||||
bt str
|
||||
bt i64
|
||||
bt char
|
||||
bt f64
|
||||
bt i32
|
||||
bt i8
|
||||
bt usize
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
|
185
crates/ide_completion/src/tests/type_pos.rs
Normal file
185
crates/ide_completion/src/tests/type_pos.rs
Normal file
|
@ -0,0 +1,185 @@
|
|||
//! Completions tests for type position.
|
||||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::completion_list;
|
||||
|
||||
fn check_with(ra_fixture: &str, expect: Expect) {
|
||||
let base = r#"
|
||||
enum Enum { TupleV(u32), RecordV { field: u32 }, UnitV }
|
||||
use self::Enum::TupleV;
|
||||
mod module {}
|
||||
|
||||
trait Trait {}
|
||||
static STATIC: Unit = Unit;
|
||||
const CONST: Unit = Unit;
|
||||
struct Record { field: u32 }
|
||||
struct Tuple(u32);
|
||||
struct Unit
|
||||
macro_rules! makro {}
|
||||
"#;
|
||||
let actual = completion_list(&format!("{}\n{}", base, ra_fixture));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn record_field_ty() {
|
||||
// FIXME: pub shouldnt show up here
|
||||
check_with(
|
||||
r#"
|
||||
struct Foo<'lt, T, const C: usize> {
|
||||
f: $0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
sp Self
|
||||
tp T
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
md module
|
||||
st Foo<…>
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tuple_struct_field() {
|
||||
// FIXME: pub should show up here
|
||||
check_with(
|
||||
r#"
|
||||
struct Foo<'lt, T, const C: usize>(f$0);
|
||||
"#,
|
||||
expect![[r#"
|
||||
sp Self
|
||||
tp T
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
md module
|
||||
st Foo<…>
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fn_return_type() {
|
||||
// FIXME: return shouldnt show up here
|
||||
check_with(
|
||||
r#"
|
||||
fn x<'lt, T, const C: usize>() -> $0
|
||||
"#,
|
||||
expect![[r#"
|
||||
kw return
|
||||
tp T
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn body_type_pos() {
|
||||
// FIXME: return shouldnt show up here
|
||||
check_with(
|
||||
r#"
|
||||
fn foo<'lt, T, const C: usize>() {
|
||||
let local = ();
|
||||
let _: $0;
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
kw return
|
||||
tp T
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
);
|
||||
check_with(
|
||||
r#"
|
||||
fn foo<'lt, T, const C: usize>() {
|
||||
let local = ();
|
||||
let _: self::$0;
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
md module
|
||||
st Unit
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_types_and_const_in_arg_list() {
|
||||
// FIXME: return shouldnt show up here
|
||||
// FIXME: we should complete the lifetime here for now
|
||||
check_with(
|
||||
r#"
|
||||
trait Trait2 {
|
||||
type Foo;
|
||||
}
|
||||
|
||||
fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
kw return
|
||||
ta Foo = type Foo;
|
||||
tp T
|
||||
cp CONST_PARAM
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
tt Trait2
|
||||
md module
|
||||
st Unit
|
||||
ct CONST
|
||||
ma makro!(…) macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
);
|
||||
check_with(
|
||||
r#"
|
||||
trait Trait2 {
|
||||
type Foo;
|
||||
}
|
||||
|
||||
fn foo<'lt, T: Trait2<self::$0>, const CONST_PARAM: usize>(_: T) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
tt Trait2
|
||||
md module
|
||||
st Unit
|
||||
ct CONST
|
||||
"#]],
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue