Add functions to base items completion test fixture
This commit is contained in:
parent
b744e3369d
commit
ea72a5136c
@ -135,61 +135,6 @@ mod tests {
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_bindings_from_let() {
|
||||
check(
|
||||
r#"
|
||||
fn quux(x: i32) {
|
||||
let y = 92;
|
||||
1 + $0;
|
||||
let z = ();
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
lc y i32
|
||||
lc x i32
|
||||
fn quux(…) fn(i32)
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_bindings_from_if_let() {
|
||||
check(
|
||||
r#"
|
||||
fn quux() {
|
||||
if let Some(x) = foo() {
|
||||
let y = 92;
|
||||
};
|
||||
if let Some(a) = bar() {
|
||||
let b = 62;
|
||||
1 + $0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
lc b i32
|
||||
lc a
|
||||
fn quux() fn()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_bindings_from_for() {
|
||||
check(
|
||||
r#"
|
||||
fn quux() {
|
||||
for x in &[1, 2, 3] { $0 }
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
lc x
|
||||
fn quux() fn()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_if_prefix_is_keyword() {
|
||||
cov_mark::check!(completes_if_prefix_is_keyword);
|
||||
|
@ -38,7 +38,7 @@ use test_utils::assert_eq_text;
|
||||
use crate::{item::CompletionKind, CompletionConfig, CompletionItem};
|
||||
|
||||
/// Lots of basic item definitions
|
||||
const BASE_FIXTURE: &str = r#"
|
||||
const BASE_ITEMS_FIXTURE: &str = r#"
|
||||
enum Enum { TupleV(u32), RecordV { field: u32 }, UnitV }
|
||||
use self::Enum::TupleV;
|
||||
mod module {}
|
||||
@ -53,6 +53,7 @@ struct Unit;
|
||||
macro_rules! makro {}
|
||||
#[rustc_builtin_macro]
|
||||
pub macro Clone {}
|
||||
fn function() {}
|
||||
"#;
|
||||
|
||||
pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
|
||||
|
@ -4,10 +4,10 @@
|
||||
//! in [crate::completions::mod_].
|
||||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::{completion_list, BASE_FIXTURE};
|
||||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}{}", BASE_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{}{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
@ -25,10 +25,10 @@ impl Tra$0
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"##]],
|
||||
)
|
||||
@ -48,10 +48,10 @@ impl Trait for Str$0
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"##]],
|
||||
)
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! Completion tests for item list position.
|
||||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::{completion_list, BASE_FIXTURE};
|
||||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}{}", BASE_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{}{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ fn in_source_file_item_list() {
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
@ -105,8 +105,8 @@ fn in_qualified_path() {
|
||||
check(
|
||||
r#"crate::$0"#,
|
||||
expect![[r##"
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
@ -170,9 +170,9 @@ fn in_impl_assoc_item_list() {
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! Completion tests for pattern position.
|
||||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::{completion_list, BASE_FIXTURE};
|
||||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(ra_fixture);
|
||||
@ -9,7 +9,7 @@ fn check(ra_fixture: &str, expect: Expect) {
|
||||
}
|
||||
|
||||
fn check_with(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
//! Completion tests for predicates and bounds.
|
||||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::{completion_list, BASE_FIXTURE};
|
||||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_FIXTURE, ra_fixture));
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
@ -130,10 +130,10 @@ impl Record {
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"##]],
|
||||
);
|
||||
|
@ -1,23 +1,10 @@
|
||||
//! Completion tests for type position.
|
||||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::completion_list;
|
||||
use crate::tests::{completion_list, BASE_ITEMS_FIXTURE};
|
||||
|
||||
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));
|
||||
let actual = completion_list(&format!("{}\n{}", BASE_ITEMS_FIXTURE, ra_fixture));
|
||||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
@ -29,7 +16,7 @@ struct Foo<'lt, T, const C: usize> {
|
||||
f: $0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
@ -42,9 +29,10 @@ struct Foo<'lt, T, const C: usize> {
|
||||
md module
|
||||
st Foo<…>
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
||||
@ -54,7 +42,7 @@ fn tuple_struct_field() {
|
||||
r#"
|
||||
struct Foo<'lt, T, const C: usize>(f$0);
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw self
|
||||
@ -69,9 +57,10 @@ struct Foo<'lt, T, const C: usize>(f$0);
|
||||
md module
|
||||
st Foo<…>
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
"##]],
|
||||
)
|
||||
}
|
||||
|
||||
@ -81,7 +70,7 @@ fn fn_return_type() {
|
||||
r#"
|
||||
fn x<'lt, T, const C: usize>() -> $0
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
@ -92,9 +81,10 @@ fn x<'lt, T, const C: usize>() -> $0
|
||||
st Tuple
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
||||
@ -107,7 +97,7 @@ fn foo<'lt, T, const C: usize>() {
|
||||
let _: $0;
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
@ -118,9 +108,10 @@ fn foo<'lt, T, const C: usize>() {
|
||||
st Tuple
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
"##]],
|
||||
);
|
||||
check_with(
|
||||
r#"
|
||||
@ -129,14 +120,15 @@ fn foo<'lt, T, const C: usize>() {
|
||||
let _: self::$0;
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
md module
|
||||
st Unit
|
||||
"#]],
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
||||
@ -150,7 +142,7 @@ trait Trait2 {
|
||||
|
||||
fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
@ -161,13 +153,14 @@ fn foo<'lt, T: Trait2<$0>, const CONST_PARAM: usize>(_: T) {}
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
tt Trait2
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
tt Trait2
|
||||
ct CONST
|
||||
ma makro!(…) macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
bt u32
|
||||
"#]],
|
||||
"##]],
|
||||
);
|
||||
check_with(
|
||||
r#"
|
||||
@ -177,15 +170,16 @@ trait Trait2 {
|
||||
|
||||
fn foo<'lt, T: Trait2<self::$0>, const CONST_PARAM: usize>(_: T) {}
|
||||
"#,
|
||||
expect![[r#"
|
||||
expect![[r##"
|
||||
tt Trait
|
||||
en Enum
|
||||
st Record
|
||||
st Tuple
|
||||
tt Trait2
|
||||
md module
|
||||
st Unit
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
tt Trait2
|
||||
ct CONST
|
||||
"#]],
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user