minor: fix test style

This commit is contained in:
Aleksey Kladov 2021-05-09 17:41:25 +03:00
parent 5637ce4250
commit edeb492782
2 changed files with 30 additions and 66 deletions

View file

@ -67,18 +67,6 @@ fn remove_newlines(edit: &mut TextEditBuilder, token: &SyntaxToken, range: TextR
fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextSize) { fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextSize) {
if token.kind() != WHITESPACE || token.text().bytes().filter(|&b| b == b'\n').count() != 1 { if token.kind() != WHITESPACE || token.text().bytes().filter(|&b| b == b'\n').count() != 1 {
let mut no_space = false;
if let Some(string) = ast::String::cast(token.clone()) {
if let Some(range) = string.open_quote_text_range() {
cov_mark::hit!(join_string_literal_open_quote);
no_space |= range.end() == offset;
}
if let Some(range) = string.close_quote_text_range() {
cov_mark::hit!(join_string_literal_close_quote);
no_space |= range.start() == offset + TextSize::of('\n');
}
}
let n_spaces_after_line_break = { let n_spaces_after_line_break = {
let suff = &token.text()[TextRange::new( let suff = &token.text()[TextRange::new(
offset - token.text_range().start() + TextSize::of('\n'), offset - token.text_range().start() + TextSize::of('\n'),

View file

@ -55,12 +55,8 @@ mod tests {
fn replace_impl_trait_with_generic_params() { fn replace_impl_trait_with_generic_params() {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"fn foo<G>(bar: $0impl Bar) {}"#,
fn foo<G>(bar: $0impl Bar) {} r#"fn foo<G, B: Bar>(bar: B) {}"#,
"#,
r#"
fn foo<G, B: Bar>(bar: B) {}
"#,
); );
} }
@ -68,12 +64,8 @@ mod tests {
fn replace_impl_trait_without_generic_params() { fn replace_impl_trait_without_generic_params() {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"fn foo(bar: $0impl Bar) {}"#,
fn foo(bar: $0impl Bar) {} r#"fn foo<B: Bar>(bar: B) {}"#,
"#,
r#"
fn foo<B: Bar>(bar: B) {}
"#,
); );
} }
@ -81,12 +73,8 @@ mod tests {
fn replace_two_impl_trait_with_generic_params() { fn replace_two_impl_trait_with_generic_params() {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"fn foo<G>(foo: impl Foo, bar: $0impl Bar) {}"#,
fn foo<G>(foo: impl Foo, bar: $0impl Bar) {} r#"fn foo<G, B: Bar>(foo: impl Foo, bar: B) {}"#,
"#,
r#"
fn foo<G, B: Bar>(foo: impl Foo, bar: B) {}
"#,
); );
} }
@ -94,12 +82,8 @@ mod tests {
fn replace_impl_trait_with_empty_generic_params() { fn replace_impl_trait_with_empty_generic_params() {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"fn foo<>(bar: $0impl Bar) {}"#,
fn foo<>(bar: $0impl Bar) {} r#"fn foo<B: Bar>(bar: B) {}"#,
"#,
r#"
fn foo<B: Bar>(bar: B) {}
"#,
); );
} }
@ -108,13 +92,13 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo< fn foo<
>(bar: $0impl Bar) {} >(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo<B: Bar fn foo<B: Bar
>(bar: B) {} >(bar: B) {}
"#, "#,
); );
} }
@ -123,12 +107,8 @@ mod tests {
fn replace_impl_trait_with_exist_generic_letter() { fn replace_impl_trait_with_exist_generic_letter() {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"fn foo<B>(bar: $0impl Bar) {}"#,
fn foo<B>(bar: $0impl Bar) {} r#"fn foo<B, C: Bar>(bar: C) {}"#,
"#,
r#"
fn foo<B, C: Bar>(bar: C) {}
"#,
); );
} }
@ -137,19 +117,19 @@ mod tests {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"
fn foo< fn foo<
G: Foo, G: Foo,
F, F,
H, H,
>(bar: $0impl Bar) {} >(bar: $0impl Bar) {}
"#, "#,
r#" r#"
fn foo< fn foo<
G: Foo, G: Foo,
F, F,
H, B: Bar H, B: Bar
>(bar: B) {} >(bar: B) {}
"#, "#,
); );
} }
@ -157,12 +137,8 @@ mod tests {
fn replace_impl_trait_multiple() { fn replace_impl_trait_multiple() {
check_assist( check_assist(
replace_impl_trait_with_generic, replace_impl_trait_with_generic,
r#" r#"fn foo(bar: $0impl Foo + Bar) {}"#,
fn foo(bar: $0impl Foo + Bar) {} r#"fn foo<F: Foo + Bar>(bar: F) {}"#,
"#,
r#"
fn foo<F: Foo + Bar>(bar: F) {}
"#,
); );
} }
} }