mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Clarify what the outline test module is for
This commit is contained in:
parent
2d696b9c9e
commit
d5947d9d48
6 changed files with 115 additions and 119 deletions
|
@ -44,3 +44,77 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
|
|||
|
||||
Some(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use crate::tests::check_edit;
|
||||
|
||||
#[test]
|
||||
fn default_completion_edit() {
|
||||
check_edit(
|
||||
"..Default::default()",
|
||||
r#"
|
||||
//- minicore: default
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
.$0
|
||||
};
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
"#,
|
||||
);
|
||||
check_edit(
|
||||
"..Default::default()",
|
||||
r#"
|
||||
//- minicore: default
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
$0
|
||||
};
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,10 +108,4 @@ mod tests {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_not_complete_snippets_in_path() {
|
||||
check(r#"fn foo(x: i32) { ::foo$0 }"#, expect![[""]]);
|
||||
check(r#"fn foo(x: i32) { ::$0 }"#, expect![[""]]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,29 +299,6 @@ mod tests {
|
|||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn name_ref_function_type_const() {
|
||||
check(
|
||||
r#"
|
||||
trait Test {
|
||||
type TestType;
|
||||
const TEST_CONST: u16;
|
||||
fn test();
|
||||
}
|
||||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
t$0
|
||||
}
|
||||
"#,
|
||||
expect![["
|
||||
ta type TestType = \n\
|
||||
ct const TEST_CONST: u16 = \n\
|
||||
fn fn test()
|
||||
"]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_completion_inside_fn() {
|
||||
check(
|
||||
|
@ -572,27 +549,6 @@ impl Test for T {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hide_implemented_fn() {
|
||||
check(
|
||||
r#"
|
||||
trait Test {
|
||||
fn foo();
|
||||
fn foo_bar();
|
||||
}
|
||||
struct T;
|
||||
|
||||
impl Test for T {
|
||||
fn foo() {}
|
||||
fn f$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn fn foo_bar()
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn generic_fn() {
|
||||
check_edit(
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
//! Most tests live in this module or its submodules unless for very specific completions like
|
||||
//! `attributes` or `lifetimes` where the completed concept is a distinct thing.
|
||||
//! Notable examples for completions that are being tested in this module's submodule are paths.
|
||||
//! Another exception are `check_edit` tests which usually live in the completion modules themselves,
|
||||
//! as the main purpose of this test module here is to give the developer an overview of whats being
|
||||
//! completed where, not how.
|
||||
|
||||
mod attribute;
|
||||
mod fn_param;
|
||||
|
|
|
@ -210,3 +210,40 @@ fn in_trait_assoc_item_list() {
|
|||
"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_trait_impl_assoc_item_list() {
|
||||
check(
|
||||
r#"
|
||||
trait Test {
|
||||
type Type0;
|
||||
type Type1;
|
||||
const CONST0: ();
|
||||
const CONST1: ();
|
||||
fn function0();
|
||||
fn function1();
|
||||
}
|
||||
|
||||
impl Test for () {
|
||||
type Type0 = ();
|
||||
const CONST0: () = ();
|
||||
fn function0() {}
|
||||
$0
|
||||
}
|
||||
"#,
|
||||
expect![[r##"
|
||||
kw pub(crate)
|
||||
kw pub
|
||||
kw unsafe
|
||||
kw fn
|
||||
kw const
|
||||
kw type
|
||||
kw self
|
||||
kw super
|
||||
kw crate
|
||||
md module
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
ma makro!(…) #[macro_export] macro_rules! makro
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use expect_test::{expect, Expect};
|
||||
|
||||
use crate::tests::{check_edit, completion_list};
|
||||
use crate::tests::completion_list;
|
||||
|
||||
fn check(ra_fixture: &str, expect: Expect) {
|
||||
let actual = completion_list(ra_fixture);
|
||||
|
@ -162,71 +162,3 @@ fn main() {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn default_completion_edit() {
|
||||
check_edit(
|
||||
"..Default::default()",
|
||||
r#"
|
||||
//- minicore: default
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
.$0
|
||||
};
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
"#,
|
||||
);
|
||||
check_edit(
|
||||
"..Default::default()",
|
||||
r#"
|
||||
//- minicore: default
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
$0
|
||||
};
|
||||
}
|
||||
"#,
|
||||
r#"
|
||||
struct Struct { foo: u32, bar: usize }
|
||||
|
||||
impl Default for Struct {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
let other = Struct {
|
||||
foo: 5,
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue