internal: cleanup tests

* ensure standard, non-indented style (should add this check to
  `fixture` some day)
* removed a couple of ignores
This commit is contained in:
Aleksey Kladov 2021-06-15 12:48:05 +03:00
parent 7786ab2d44
commit 1e100e8b3e
3 changed files with 600 additions and 613 deletions

View File

@ -216,7 +216,7 @@ mod tests {
cov_mark::check!(qualify_path_unqualified_name);
check_assist(
qualify_path,
r"
r#"
mod std {
pub mod fmt {
pub struct Formatter;
@ -226,8 +226,8 @@ mod tests {
use std::fmt;
$0Formatter
",
r"
"#,
r#"
mod std {
pub mod fmt {
pub struct Formatter;
@ -237,7 +237,7 @@ mod tests {
use std::fmt;
fmt::Formatter
",
"#,
);
}
@ -245,20 +245,20 @@ mod tests {
fn applicable_when_found_an_import() {
check_assist(
qualify_path,
r"
r#"
$0PubStruct
pub mod PubMod {
pub struct PubStruct;
}
",
r"
"#,
r#"
PubMod::PubStruct
pub mod PubMod {
pub struct PubStruct;
}
",
"#,
);
}
@ -266,7 +266,7 @@ mod tests {
fn applicable_in_macros() {
check_assist(
qualify_path,
r"
r#"
macro_rules! foo {
($i:ident) => { fn foo(a: $i) {} }
}
@ -275,8 +275,8 @@ mod tests {
pub mod PubMod {
pub struct PubStruct;
}
",
r"
"#,
r#"
macro_rules! foo {
($i:ident) => { fn foo(a: $i) {} }
}
@ -285,7 +285,7 @@ mod tests {
pub mod PubMod {
pub struct PubStruct;
}
",
"#,
);
}
@ -293,7 +293,7 @@ mod tests {
fn applicable_when_found_multiple_imports() {
check_assist(
qualify_path,
r"
r#"
PubSt$0ruct
pub mod PubMod1 {
@ -305,8 +305,8 @@ mod tests {
pub mod PubMod3 {
pub struct PubStruct;
}
",
r"
"#,
r#"
PubMod3::PubStruct
pub mod PubMod1 {
@ -318,7 +318,7 @@ mod tests {
pub mod PubMod3 {
pub struct PubStruct;
}
",
"#,
);
}
@ -326,7 +326,7 @@ mod tests {
fn not_applicable_for_already_imported_types() {
check_assist_not_applicable(
qualify_path,
r"
r#"
use PubMod::PubStruct;
PubStruct$0
@ -334,7 +334,7 @@ mod tests {
pub mod PubMod {
pub struct PubStruct;
}
",
"#,
);
}
@ -342,35 +342,32 @@ mod tests {
fn not_applicable_for_types_with_private_paths() {
check_assist_not_applicable(
qualify_path,
r"
r#"
PrivateStruct$0
pub mod PubMod {
struct PrivateStruct;
}
",
"#,
);
}
#[test]
fn not_applicable_when_no_imports_found() {
check_assist_not_applicable(
qualify_path,
"
PubStruct$0",
);
check_assist_not_applicable(qualify_path, r#"PubStruct$0"#);
}
#[test]
fn not_applicable_in_import_statements() {
check_assist_not_applicable(
qualify_path,
r"
r#"
use PubStruct$0;
pub mod PubMod {
pub struct PubStruct;
}",
}
"#,
);
}
@ -378,20 +375,20 @@ mod tests {
fn qualify_function() {
check_assist(
qualify_path,
r"
r#"
test_function$0
pub mod PubMod {
pub fn test_function() {};
}
",
r"
"#,
r#"
PubMod::test_function
pub mod PubMod {
pub fn test_function() {};
}
",
"#,
);
}
@ -399,7 +396,7 @@ mod tests {
fn qualify_macro() {
check_assist(
qualify_path,
r"
r#"
//- /lib.rs crate:crate_with_macro
#[macro_export]
macro_rules! foo {
@ -410,12 +407,12 @@ macro_rules! foo {
fn main() {
foo$0
}
",
r"
"#,
r#"
fn main() {
crate_with_macro::foo
}
",
"#,
);
}
@ -423,13 +420,13 @@ fn main() {
fn qualify_path_target() {
check_assist_target(
qualify_path,
r"
r#"
struct AssistInfo {
group_label: Option<$0GroupLabel>,
}
mod m { pub struct GroupLabel; }
",
"#,
"GroupLabel",
)
}
@ -438,7 +435,7 @@ fn main() {
fn not_applicable_when_path_start_is_imported() {
check_assist_not_applicable(
qualify_path,
r"
r#"
pub mod mod1 {
pub mod mod2 {
pub mod mod3 {
@ -451,7 +448,7 @@ fn main() {
fn main() {
mod2::mod3::TestStruct$0
}
",
"#,
);
}
@ -459,7 +456,7 @@ fn main() {
fn not_applicable_for_imported_function() {
check_assist_not_applicable(
qualify_path,
r"
r#"
pub mod test_mod {
pub fn test_function() {}
}
@ -468,7 +465,7 @@ fn main() {
fn main() {
test_function$0
}
",
"#,
);
}
@ -476,7 +473,7 @@ fn main() {
fn associated_struct_function() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub struct TestStruct {}
impl TestStruct {
@ -487,8 +484,8 @@ fn main() {
fn main() {
TestStruct::test_function$0
}
",
r"
"#,
r#"
mod test_mod {
pub struct TestStruct {}
impl TestStruct {
@ -499,7 +496,7 @@ fn main() {
fn main() {
test_mod::TestStruct::test_function
}
",
"#,
);
}
@ -508,7 +505,7 @@ fn main() {
cov_mark::check!(qualify_path_qualifier_start);
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub struct TestStruct {}
impl TestStruct {
@ -519,8 +516,8 @@ fn main() {
fn main() {
TestStruct::TEST_CONST$0
}
",
r"
"#,
r#"
mod test_mod {
pub struct TestStruct {}
impl TestStruct {
@ -531,16 +528,16 @@ fn main() {
fn main() {
test_mod::TestStruct::TEST_CONST
}
",
"#,
);
}
#[test]
#[ignore = "FIXME: non-trait assoc items completion is unsupported yet, see FIXME in the import_assets.rs for more details"]
fn associated_struct_const_unqualified() {
check_assist(
// FIXME: non-trait assoc items completion is unsupported yet, see FIXME in the import_assets.rs for more details
check_assist_not_applicable(
qualify_path,
r"
r#"
mod test_mod {
pub struct TestStruct {}
impl TestStruct {
@ -551,19 +548,7 @@ fn main() {
fn main() {
TEST_CONST$0
}
",
r"
mod test_mod {
pub struct TestStruct {}
impl TestStruct {
const TEST_CONST: u8 = 42;
}
}
fn main() {
test_mod::TestStruct::TEST_CONST
}
",
"#,
);
}
@ -571,7 +556,7 @@ fn main() {
fn associated_trait_function() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_function();
@ -585,8 +570,8 @@ fn main() {
fn main() {
test_mod::TestStruct::test_function$0
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
fn test_function();
@ -600,7 +585,7 @@ fn main() {
fn main() {
<test_mod::TestStruct as test_mod::TestTrait>::test_function
}
",
"#,
);
}
@ -608,7 +593,7 @@ fn main() {
fn not_applicable_for_imported_trait_for_function() {
check_assist_not_applicable(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_function();
@ -632,7 +617,7 @@ fn main() {
fn main() {
test_mod::TestEnum::test_function$0;
}
",
"#,
)
}
@ -641,7 +626,7 @@ fn main() {
cov_mark::check!(qualify_path_trait_assoc_item);
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
const TEST_CONST: u8;
@ -655,8 +640,8 @@ fn main() {
fn main() {
test_mod::TestStruct::TEST_CONST$0
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
const TEST_CONST: u8;
@ -670,7 +655,7 @@ fn main() {
fn main() {
<test_mod::TestStruct as test_mod::TestTrait>::TEST_CONST
}
",
"#,
);
}
@ -678,7 +663,7 @@ fn main() {
fn not_applicable_for_imported_trait_for_const() {
check_assist_not_applicable(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
const TEST_CONST: u8;
@ -702,7 +687,7 @@ fn main() {
fn main() {
test_mod::TestEnum::TEST_CONST$0;
}
",
"#,
)
}
@ -711,7 +696,7 @@ fn main() {
cov_mark::check!(qualify_path_trait_method);
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(&self);
@ -726,8 +711,8 @@ fn main() {
let test_struct = test_mod::TestStruct {};
test_struct.test_meth$0od()
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(&self);
@ -742,7 +727,7 @@ fn main() {
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method(&test_struct)
}
",
"#,
);
}
@ -750,7 +735,7 @@ fn main() {
fn trait_method_multi_params() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(&self, test: i32);
@ -765,8 +750,8 @@ fn main() {
let test_struct = test_mod::TestStruct {};
test_struct.test_meth$0od(42)
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(&self, test: i32);
@ -781,7 +766,7 @@ fn main() {
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method(&test_struct, 42)
}
",
"#,
);
}
@ -789,7 +774,7 @@ fn main() {
fn trait_method_consume() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(self);
@ -804,8 +789,8 @@ fn main() {
let test_struct = test_mod::TestStruct {};
test_struct.test_meth$0od()
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(self);
@ -820,7 +805,7 @@ fn main() {
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method(test_struct)
}
",
"#,
);
}
@ -828,7 +813,7 @@ fn main() {
fn trait_method_cross_crate() {
check_assist(
qualify_path,
r"
r#"
//- /main.rs crate:main deps:dep
fn main() {
let test_struct = dep::test_mod::TestStruct {};
@ -844,13 +829,13 @@ fn main() {
fn test_method(&self) {}
}
}
",
r"
"#,
r#"
fn main() {
let test_struct = dep::test_mod::TestStruct {};
dep::test_mod::TestTrait::test_method(&test_struct)
}
",
"#,
);
}
@ -858,7 +843,7 @@ fn main() {
fn assoc_fn_cross_crate() {
check_assist(
qualify_path,
r"
r#"
//- /main.rs crate:main deps:dep
fn main() {
dep::test_mod::TestStruct::test_func$0tion
@ -873,12 +858,12 @@ fn main() {
fn test_function() {}
}
}
",
r"
"#,
r#"
fn main() {
<dep::test_mod::TestStruct as dep::test_mod::TestTrait>::test_function
}
",
"#,
);
}
@ -886,7 +871,7 @@ fn main() {
fn assoc_const_cross_crate() {
check_assist(
qualify_path,
r"
r#"
//- /main.rs crate:main deps:dep
fn main() {
dep::test_mod::TestStruct::CONST$0
@ -901,12 +886,12 @@ fn main() {
const CONST: bool = true;
}
}
",
r"
"#,
r#"
fn main() {
<dep::test_mod::TestStruct as dep::test_mod::TestTrait>::CONST
}
",
"#,
);
}
@ -914,7 +899,7 @@ fn main() {
fn assoc_fn_as_method_cross_crate() {
check_assist_not_applicable(
qualify_path,
r"
r#"
//- /main.rs crate:main deps:dep
fn main() {
let test_struct = dep::test_mod::TestStruct {};
@ -930,7 +915,7 @@ fn main() {
fn test_function() {}
}
}
",
"#,
);
}
@ -938,7 +923,7 @@ fn main() {
fn private_trait_cross_crate() {
check_assist_not_applicable(
qualify_path,
r"
r#"
//- /main.rs crate:main deps:dep
fn main() {
let test_struct = dep::test_mod::TestStruct {};
@ -954,7 +939,7 @@ fn main() {
fn test_method(&self) {}
}
}
",
"#,
);
}
@ -962,7 +947,7 @@ fn main() {
fn not_applicable_for_imported_trait_for_method() {
check_assist_not_applicable(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_method(&self);
@ -987,7 +972,7 @@ fn main() {
let one = test_mod::TestEnum::One;
one.test$0_method();
}
",
"#,
)
}
@ -1114,7 +1099,7 @@ fn main() {}
fn keep_generic_annotations_leading_colon() {
check_assist(
qualify_path,
r"
r#"
//- /lib.rs crate:dep
pub mod generic { pub struct Thing<'a, T>(&'a T); }
@ -1122,7 +1107,7 @@ pub mod generic { pub struct Thing<'a, T>(&'a T); }
fn foo() -> Thin$0g::<'static, ()> {}
fn main() {}
",
"#,
r"
fn foo() -> dep::generic::Thing::<'static, ()> {}
@ -1135,7 +1120,7 @@ fn main() {}
fn associated_struct_const_generic() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub struct TestStruct<T> {}
impl<T> TestStruct<T> {
@ -1146,8 +1131,8 @@ fn main() {}
fn main() {
TestStruct::<()>::TEST_CONST$0
}
",
r"
"#,
r#"
mod test_mod {
pub struct TestStruct<T> {}
impl<T> TestStruct<T> {
@ -1158,7 +1143,7 @@ fn main() {}
fn main() {
test_mod::TestStruct::<()>::TEST_CONST
}
",
"#,
);
}
@ -1166,7 +1151,7 @@ fn main() {}
fn associated_trait_const_generic() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
const TEST_CONST: u8;
@ -1180,8 +1165,8 @@ fn main() {}
fn main() {
test_mod::TestStruct::<()>::TEST_CONST$0
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
const TEST_CONST: u8;
@ -1195,7 +1180,7 @@ fn main() {}
fn main() {
<test_mod::TestStruct::<()> as test_mod::TestTrait>::TEST_CONST
}
",
"#,
);
}
@ -1203,7 +1188,7 @@ fn main() {}
fn trait_method_generic() {
check_assist(
qualify_path,
r"
r#"
mod test_mod {
pub trait TestTrait {
fn test_method<T>(&self);
@ -1218,8 +1203,8 @@ fn main() {}
let test_struct = test_mod::TestStruct {};
test_struct.test_meth$0od::<()>()
}
",
r"
"#,
r#"
mod test_mod {
pub trait TestTrait {
fn test_method<T>(&self);
@ -1234,7 +1219,7 @@ fn main() {}
let test_struct = test_mod::TestStruct {};
test_mod::TestTrait::test_method::<()>(&test_struct)
}
",
"#,
);
}
}

View File

@ -105,12 +105,13 @@ fn foo<B: Bar
}
#[test]
#[ignore = "This case is very rare but there is no simple solutions to fix it."]
fn replace_impl_trait_with_exist_generic_letter() {
// FIXME: This is wrong, we should pick a different name if the one we
// want is already bound.
check_assist(
replace_impl_trait_with_generic,
r#"fn foo<B>(bar: $0impl Bar) {}"#,
r#"fn foo<B, C: Bar>(bar: C) {}"#,
r#"fn foo<B, B: Bar>(bar: B) {}"#,
);
}

View File

@ -511,13 +511,14 @@ use std::io;
}
#[test]
#[ignore] // FIXME: Support this
fn split_out_merge() {
// FIXME: This is suboptimal, we want to get `use std::fmt::{self, Result}`
// instead.
check_module(
"std::fmt::Result",
r"use std::{fmt, io};",
r"use std::fmt::{self, Result};
use std::io;",
r"use std::fmt::Result;
use std::{fmt, io};",
)
}