chore: add a test for formatting assignment patterns
This commit is contained in:
parent
945b4155cd
commit
7b32d4ae30
|
@ -728,7 +728,6 @@ impl<'comments> Formatter<'comments> {
|
|||
.append(join(patterns, break_(",", ", ")))
|
||||
.nest(INDENT)
|
||||
.append(break_(",", " "))
|
||||
.append(break_("", " "))
|
||||
.append(symbol)
|
||||
.append(self.case_clause_value(value))
|
||||
}
|
||||
|
|
|
@ -473,6 +473,34 @@ fn format_newline_module_comments() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_many_assignment_patterns() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn backpassing() -> Int {
|
||||
|
||||
let
|
||||
elem, accumulator, wow,
|
||||
who,
|
||||
thing,
|
||||
what,
|
||||
idk,
|
||||
wee,
|
||||
will,
|
||||
it,
|
||||
break,
|
||||
|
||||
|
||||
|
||||
<- fold([1, 2, 3],
|
||||
0)
|
||||
|
||||
elem + accumulator
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn format_bytearray_literals() {
|
||||
assert_format!(
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn backpassing() -> Int {\n\n let\n elem, accumulator, wow,\n who,\n thing,\n what,\n idk,\n wee,\n will,\n it,\n break,\n\n\n\n <- fold([1, 2, 3],\n 0)\n\n elem + accumulator\n}\n"
|
||||
---
|
||||
fn backpassing() -> Int {
|
||||
let
|
||||
elem,
|
||||
accumulator,
|
||||
wow,
|
||||
who,
|
||||
thing,
|
||||
what,
|
||||
idk,
|
||||
wee,
|
||||
will,
|
||||
it,
|
||||
break,
|
||||
<- fold([1, 2, 3], 0)
|
||||
|
||||
elem + accumulator
|
||||
}
|
|
@ -1894,8 +1894,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
|||
.iter()
|
||||
.map(|ap| ap.pattern.location())
|
||||
.reduce(|acc, loc| acc.union(loc))
|
||||
.unwrap_or(location)
|
||||
.map_end(|current| current - 1),
|
||||
.unwrap_or(location),
|
||||
});
|
||||
}
|
||||
_ => prefix.push(expression),
|
||||
|
|
Loading…
Reference in New Issue