From d5f6a5f5e29df3005533502b49f78daae314ac5b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Feb 2019 21:54:13 +0300 Subject: move testing functions --- crates/ra_ide_api/src/completion.rs | 3 +++ crates/ra_ide_api/src/completion/complete_dot.rs | 3 +-- crates/ra_ide_api/src/completion/complete_fn_param.rs | 3 +-- crates/ra_ide_api/src/completion/complete_keyword.rs | 3 +-- crates/ra_ide_api/src/completion/complete_path.rs | 7 ++----- crates/ra_ide_api/src/completion/complete_postfix.rs | 3 +-- crates/ra_ide_api/src/completion/complete_scope.rs | 3 +-- crates/ra_ide_api/src/completion/complete_snippet.rs | 3 +-- crates/ra_ide_api/src/completion/complete_struct_literal.rs | 4 ++-- crates/ra_ide_api/src/completion/presentation.rs | 2 +- 10 files changed, 14 insertions(+), 20 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs index e13baa7a9..fbfd7e3e7 100644 --- a/crates/ra_ide_api/src/completion.rs +++ b/crates/ra_ide_api/src/completion.rs @@ -21,7 +21,10 @@ use crate::{ completion_item::{Completions, CompletionKind}, completion_context::CompletionContext, }, + }; +#[cfg(test)] +use crate::completion::completion_item::{do_completion, check_completion}; pub use crate::completion::completion_item::{CompletionItem, CompletionItemKind, InsertTextFormat}; diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index be76b997e..d5ad2e79f 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -58,8 +58,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty #[cfg(test)] mod tests { - use crate::completion::*; - use crate::completion::completion_item::check_completion; + use crate::completion::{check_completion, CompletionKind}; fn check_ref_completion(name: &str, code: &str) { check_completion(name, code, CompletionKind::Reference); diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs index 4d6416284..ffdc744b2 100644 --- a/crates/ra_ide_api/src/completion/complete_fn_param.rs +++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs @@ -54,8 +54,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext) #[cfg(test)] mod tests { - use crate::completion::*; - use crate::completion::completion_item::check_completion; + use crate::completion::{check_completion, CompletionKind}; fn check_magic_completion(name: &str, code: &str) { check_completion(name, code, CompletionKind::Magic); diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs index b667381a7..841c0c554 100644 --- a/crates/ra_ide_api/src/completion/complete_keyword.rs +++ b/crates/ra_ide_api/src/completion/complete_keyword.rs @@ -109,8 +109,7 @@ fn complete_return( #[cfg(test)] mod tests { - use crate::completion::CompletionKind; - use crate::completion::completion_item::check_completion; + use crate::completion::{check_completion, CompletionKind}; fn check_keyword_completion(name: &str, code: &str) { check_completion(name, code, CompletionKind::Keyword); diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 8e453b0e0..629a7ee77 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -57,13 +57,10 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { #[cfg(test)] mod tests { - use crate::completion::{ - CompletionKind, - completion_item::{check_completion, do_completion}, -}; - use test_utils::covers; + use crate::completion::{CompletionKind, check_completion, do_completion}; + fn check_reference_completion(code: &str, expected_completions: &str) { check_completion(code, expected_completions, CompletionKind::Reference); } diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs index ce3d6ed3c..4dfa5f176 100644 --- a/crates/ra_ide_api/src/completion/complete_postfix.rs +++ b/crates/ra_ide_api/src/completion/complete_postfix.rs @@ -56,8 +56,7 @@ pub(super) fn complete_postfix(acc: &mut Completions, ctx: &CompletionContext) { #[cfg(test)] mod tests { - use crate::completion::completion_item::CompletionKind; - use crate::completion::completion_item::check_completion; + use crate::completion::{CompletionKind, check_completion}; fn check_snippet_completion(test_name: &str, code: &str) { check_completion(test_name, code, CompletionKind::Postfix); diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs index b44b943ae..6146b7bb6 100644 --- a/crates/ra_ide_api/src/completion/complete_scope.rs +++ b/crates/ra_ide_api/src/completion/complete_scope.rs @@ -11,8 +11,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) { #[cfg(test)] mod tests { - use crate::completion::CompletionKind; - use crate::completion::completion_item::check_completion; + use crate::completion::{CompletionKind, check_completion}; fn check_reference_completion(name: &str, code: &str) { check_completion(name, code, CompletionKind::Reference); diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs index aa3a16fa2..e1df9e625 100644 --- a/crates/ra_ide_api/src/completion/complete_snippet.rs +++ b/crates/ra_ide_api/src/completion/complete_snippet.rs @@ -36,8 +36,7 @@ fn ${1:feature}() { #[cfg(test)] mod tests { - use crate::completion::CompletionKind; - use crate::completion::completion_item::check_completion; + use crate::completion::{CompletionKind, check_completion}; fn check_snippet_completion(name: &str, code: &str) { check_completion(name, code, CompletionKind::Snippet); diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs index 1b8fb0768..afb092f59 100644 --- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs +++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs @@ -34,10 +34,10 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon #[cfg(test)] mod tests { use insta::assert_debug_snapshot_matches; - use crate::completion::{CompletionItem, CompletionKind}; + use crate::completion::{CompletionItem, CompletionKind, do_completion}; fn complete(code: &str) -> Vec { - crate::completion::completion_item::do_completion(code, CompletionKind::Reference) + do_completion(code, CompletionKind::Reference) } #[test] diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 0ead52032..6454436c9 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -168,7 +168,7 @@ impl Completions { mod tests { use test_utils::covers; - use crate::completion::{CompletionKind, completion_item::check_completion}; + use crate::completion::{CompletionKind, check_completion}; fn check_reference_completion(code: &str, expected_completions: &str) { check_completion(code, expected_completions, CompletionKind::Reference); -- cgit v1.2.3