test: adjust formatter tests after latest tweaks
This commit is contained in:
parent
151db8d4ae
commit
a44b5e1a77
|
@ -1459,7 +1459,6 @@ impl<'comments> Formatter<'comments> {
|
|||
|
||||
fn clause<'a>(&mut self, clause: &'a UntypedClause, index: u32) -> Document<'a> {
|
||||
let space_before = self.pop_empty_lines(clause.location.start);
|
||||
let after_position = clause.location.end;
|
||||
let clause_doc = join(
|
||||
clause.patterns.iter().map(|p| self.pattern(p)),
|
||||
" | ".to_doc(),
|
||||
|
@ -1469,9 +1468,6 @@ impl<'comments> Formatter<'comments> {
|
|||
Some(guard) => clause_doc.append(" if ").append(self.clause_guard(guard)),
|
||||
};
|
||||
|
||||
// Remove any unused empty lines within the clause
|
||||
self.pop_empty_lines(after_position);
|
||||
|
||||
if index == 0 {
|
||||
clause_doc
|
||||
} else if space_before {
|
||||
|
|
|
@ -138,6 +138,7 @@ fn test_format_when() {
|
|||
bar()
|
||||
|
||||
14
|
||||
|
||||
}
|
||||
False ->
|
||||
|
||||
|
@ -155,8 +156,8 @@ fn test_format_when() {
|
|||
|
||||
14
|
||||
}
|
||||
False ->
|
||||
42
|
||||
|
||||
False -> 42
|
||||
}
|
||||
}
|
||||
"#};
|
||||
|
@ -216,8 +217,7 @@ fn test_format_nested_when_if() {
|
|||
when xs is {
|
||||
[] ->
|
||||
[]
|
||||
[_x, ..rest] ->
|
||||
drop(rest, n - 1)
|
||||
[_x, ..rest] -> drop(rest, n - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,18 +246,14 @@ fn test_format_nested_when() {
|
|||
let expected = indoc! {r#"
|
||||
fn foo() {
|
||||
when a is {
|
||||
None ->
|
||||
"foo"
|
||||
None -> "foo"
|
||||
Some(b) ->
|
||||
when b is {
|
||||
None ->
|
||||
"foo"
|
||||
None -> "foo"
|
||||
Some(c) ->
|
||||
when c is {
|
||||
None ->
|
||||
"foo"
|
||||
Some(_) ->
|
||||
"foo"
|
||||
None -> "foo"
|
||||
Some(_) -> "foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -416,10 +412,8 @@ fn test_nested_function_calls() {
|
|||
),
|
||||
),
|
||||
when output.datum is {
|
||||
InlineDatum(_) ->
|
||||
True
|
||||
_ ->
|
||||
error @"expected inline datum"
|
||||
InlineDatum(_) -> True
|
||||
_ -> error @"expected inline datum"
|
||||
},
|
||||
]
|
||||
|> list.and
|
||||
|
@ -468,10 +462,8 @@ fn format_trace_todo_error() {
|
|||
|
||||
fn foo_3() {
|
||||
when x is {
|
||||
Foo ->
|
||||
True
|
||||
_ ->
|
||||
error
|
||||
Foo -> True
|
||||
_ -> error
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,24 +586,18 @@ fn test_newline_module_comments() {
|
|||
#[test]
|
||||
fn test_bytearray_literals() {
|
||||
let src = indoc! {r#"
|
||||
const foo_const_array =
|
||||
#[102, 111, 111]
|
||||
const foo_const_array = #[102, 111, 111]
|
||||
|
||||
const foo_const_hex =
|
||||
#"666f6f"
|
||||
const foo_const_hex = #"666f6f"
|
||||
|
||||
const foo_const_utf8 =
|
||||
"foo"
|
||||
const foo_const_utf8 = "foo"
|
||||
|
||||
fn foo() {
|
||||
let foo_const_array =
|
||||
#[102, 111, 111]
|
||||
let foo_const_array = #[102, 111, 111]
|
||||
|
||||
let foo_const_hex =
|
||||
#"666f6f"
|
||||
let foo_const_hex = #"666f6f"
|
||||
|
||||
let foo_const_utf8 =
|
||||
"foo"
|
||||
let foo_const_utf8 = "foo"
|
||||
}
|
||||
"#};
|
||||
|
||||
|
@ -621,12 +607,10 @@ fn test_bytearray_literals() {
|
|||
#[test]
|
||||
fn test_string_literal() {
|
||||
let src = indoc! {r#"
|
||||
const foo_const: String =
|
||||
@"foo"
|
||||
const foo_const: String = @"foo"
|
||||
|
||||
fn foo() {
|
||||
let foo_var: String =
|
||||
@"foo"
|
||||
let foo_var: String = @"foo"
|
||||
}
|
||||
"#};
|
||||
|
||||
|
@ -791,16 +775,11 @@ fn match_record() {
|
|||
let src = indoc! { r#"
|
||||
fn foo() {
|
||||
when bar is {
|
||||
Bar { a, b, c } ->
|
||||
Void
|
||||
Bar { a, .. } ->
|
||||
Void
|
||||
Bar { .. } ->
|
||||
Void
|
||||
Bar(a, b, c) ->
|
||||
Void
|
||||
Bar(..) ->
|
||||
Void
|
||||
Bar { a, b, c } -> Void
|
||||
Bar { a, .. } -> Void
|
||||
Bar { .. } -> Void
|
||||
Bar(a, b, c) -> Void
|
||||
Bar(..) -> Void
|
||||
}
|
||||
}
|
||||
"#};
|
||||
|
|
Loading…
Reference in New Issue