fix tidy test

This commit is contained in:
bravomikekilo 2019-11-22 03:18:22 +08:00
parent 8a8be06219
commit 1ebfa908d5

View file

@ -2,8 +2,8 @@ use hir::db::HirDatabase;
use ra_syntax::ast::{self, AstNode}; use ra_syntax::ast::{self, AstNode};
use ra_syntax::{TextRange, TextUnit}; use ra_syntax::{TextRange, TextUnit};
use crate::{Assist, AssistCtx, AssistId};
use super::apply_demorgan::undo_negation; use super::apply_demorgan::undo_negation;
use crate::{Assist, AssistCtx, AssistId};
// Assist: invert_if // Assist: invert_if
// //
@ -24,7 +24,6 @@ use super::apply_demorgan::undo_negation;
// } // }
// ``` // ```
pub(crate) fn invert_if(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { pub(crate) fn invert_if(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
let expr = ctx.find_node_at_offset::<ast::IfExpr>()?; let expr = ctx.find_node_at_offset::<ast::IfExpr>()?;
let expr_range = expr.syntax().text_range(); let expr_range = expr.syntax().text_range();
@ -49,12 +48,9 @@ pub(crate) fn invert_if(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
edit.replace(else_range, then_node.text()); edit.replace(else_range, then_node.text());
edit.replace(then_range, else_node.text()); edit.replace(then_range, else_node.text());
}) })
} else { } else {
None None
} }
} }
#[cfg(test)] #[cfg(test)]
@ -65,12 +61,20 @@ mod tests {
#[test] #[test]
fn invert_if_remove_inequality() { fn invert_if_remove_inequality() {
check_assist(invert_if, "fn f() { i<|>f x != 3 {1} else {3 + 2} }", "fn f() { i<|>f x == 3 {3 + 2} else {1} }") check_assist(
invert_if,
"fn f() { i<|>f x != 3 {1} else {3 + 2} }",
"fn f() { i<|>f x == 3 {3 + 2} else {1} }",
)
} }
#[test] #[test]
fn invert_if_remove_not() { fn invert_if_remove_not() {
check_assist(invert_if, "fn f() { <|>if !cond {3 * 2} else {1} }", "fn f() { <|>if cond {1} else {3 * 2} }") check_assist(
invert_if,
"fn f() { <|>if !cond {3 * 2} else {1} }",
"fn f() { <|>if cond {1} else {3 * 2} }",
)
} }
#[test] #[test]