Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/tests/item_list.rs')
-rw-r--r--crates/ide-completion/src/tests/item_list.rs53
1 files changed, 24 insertions, 29 deletions
diff --git a/crates/ide-completion/src/tests/item_list.rs b/crates/ide-completion/src/tests/item_list.rs
index d3d52dc6df..841c42123a 100644
--- a/crates/ide-completion/src/tests/item_list.rs
+++ b/crates/ide-completion/src/tests/item_list.rs
@@ -1,16 +1,11 @@
//! Completion tests for item list position.
-use expect_test::{expect, Expect};
+use expect_test::expect;
-use crate::tests::{check_edit, check_empty, completion_list, BASE_ITEMS_FIXTURE};
-
-fn check(ra_fixture: &str, expect: Expect) {
- let actual = completion_list(&format!("{BASE_ITEMS_FIXTURE}{ra_fixture}"));
- expect.assert_eq(&actual)
-}
+use crate::tests::{check, check_edit, check_with_base_items};
#[test]
fn in_mod_item_list() {
- check(
+ check_with_base_items(
r#"mod tests { $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -43,7 +38,7 @@ fn in_mod_item_list() {
#[test]
fn in_source_file_item_list() {
- check(
+ check_with_base_items(
r#"$0"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -76,7 +71,7 @@ fn in_source_file_item_list() {
#[test]
fn in_item_list_after_attr() {
- check(
+ check_with_base_items(
r#"#[attr] $0"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -109,7 +104,7 @@ fn in_item_list_after_attr() {
#[test]
fn in_qualified_path() {
- check(
+ check_with_base_items(
r#"crate::$0"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -120,7 +115,7 @@ fn in_qualified_path() {
#[test]
fn after_unsafe_token() {
- check(
+ check_with_base_items(
r#"unsafe $0"#,
expect![[r#"
kw async
@@ -134,7 +129,7 @@ fn after_unsafe_token() {
#[test]
fn after_async_token() {
- check(
+ check_with_base_items(
r#"async $0"#,
expect![[r#"
kw fn
@@ -145,7 +140,7 @@ fn after_async_token() {
#[test]
fn after_visibility() {
- check(
+ check_with_base_items(
r#"pub $0"#,
expect![[r#"
kw async
@@ -167,7 +162,7 @@ fn after_visibility() {
#[test]
fn after_visibility_unsafe() {
- check(
+ check_with_base_items(
r#"pub unsafe $0"#,
expect![[r#"
kw async
@@ -179,7 +174,7 @@ fn after_visibility_unsafe() {
#[test]
fn in_impl_assoc_item_list() {
- check(
+ check_with_base_items(
r#"impl Struct { $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -199,7 +194,7 @@ fn in_impl_assoc_item_list() {
#[test]
fn in_impl_assoc_item_list_after_attr() {
- check(
+ check_with_base_items(
r#"impl Struct { #[attr] $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -219,7 +214,7 @@ fn in_impl_assoc_item_list_after_attr() {
#[test]
fn in_trait_assoc_item_list() {
- check(
+ check_with_base_items(
r"trait Foo { $0 }",
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -237,7 +232,7 @@ fn in_trait_assoc_item_list() {
#[test]
fn in_trait_assoc_fn_missing_body() {
- check(
+ check_with_base_items(
r#"trait Foo { fn function(); $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -255,7 +250,7 @@ fn in_trait_assoc_fn_missing_body() {
#[test]
fn in_trait_assoc_const_missing_body() {
- check(
+ check_with_base_items(
r#"trait Foo { const CONST: (); $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -273,7 +268,7 @@ fn in_trait_assoc_const_missing_body() {
#[test]
fn in_trait_assoc_type_aliases_missing_ty() {
- check(
+ check_with_base_items(
r#"trait Foo { type Type; $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -291,7 +286,7 @@ fn in_trait_assoc_type_aliases_missing_ty() {
#[test]
fn in_trait_impl_assoc_item_list() {
- check(
+ check_with_base_items(
r#"
trait Test {
type Type0;
@@ -326,7 +321,7 @@ impl Test for () {
#[test]
fn in_trait_impl_no_unstable_item_on_stable() {
- check_empty(
+ check(
r#"
trait Test {
#[unstable]
@@ -350,7 +345,7 @@ impl Test for () {
#[test]
fn in_trait_impl_unstable_item_on_nightly() {
- check_empty(
+ check(
r#"
//- toolchain:nightly
trait Test {
@@ -378,7 +373,7 @@ impl Test for () {
#[test]
fn after_unit_struct() {
- check(
+ check_with_base_items(
r#"struct S; f$0"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -500,7 +495,7 @@ type O = $0;
#[test]
fn inside_extern_blocks() {
// Should suggest `fn`, `static`, `unsafe`
- check(
+ check_with_base_items(
r#"extern { $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -517,7 +512,7 @@ fn inside_extern_blocks() {
);
// Should suggest `fn`, `static`, `safe`, `unsafe`
- check(
+ check_with_base_items(
r#"unsafe extern { $0 }"#,
expect![[r#"
ma makro!(…) macro_rules! makro
@@ -534,7 +529,7 @@ fn inside_extern_blocks() {
"#]],
);
- check(
+ check_with_base_items(
r#"unsafe extern { pub safe $0 }"#,
expect![[r#"
kw fn
@@ -542,7 +537,7 @@ fn inside_extern_blocks() {
"#]],
);
- check(
+ check_with_base_items(
r#"unsafe extern { pub unsafe $0 }"#,
expect![[r#"
kw fn