chore: add a test for formatting assignment patterns
This commit is contained in:
parent
945b4155cd
commit
7b32d4ae30
|
@ -727,8 +727,7 @@ impl<'comments> Formatter<'comments> {
|
||||||
.append(break_("", " "))
|
.append(break_("", " "))
|
||||||
.append(join(patterns, break_(",", ", ")))
|
.append(join(patterns, break_(",", ", ")))
|
||||||
.nest(INDENT)
|
.nest(INDENT)
|
||||||
.append(break_(",", ""))
|
.append(break_(",", " "))
|
||||||
.append(break_("", " "))
|
|
||||||
.append(symbol)
|
.append(symbol)
|
||||||
.append(self.case_clause_value(value))
|
.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]
|
#[test]
|
||||||
fn format_bytearray_literals() {
|
fn format_bytearray_literals() {
|
||||||
assert_format!(
|
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()
|
.iter()
|
||||||
.map(|ap| ap.pattern.location())
|
.map(|ap| ap.pattern.location())
|
||||||
.reduce(|acc, loc| acc.union(loc))
|
.reduce(|acc, loc| acc.union(loc))
|
||||||
.unwrap_or(location)
|
.unwrap_or(location),
|
||||||
.map_end(|current| current - 1),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_ => prefix.push(expression),
|
_ => prefix.push(expression),
|
||||||
|
|
Loading…
Reference in New Issue