chore: add a test for formatting assignment patterns

This commit is contained in:
rvcas 2024-03-11 19:08:51 -04:00 committed by Lucas
parent 945b4155cd
commit 7b32d4ae30
4 changed files with 51 additions and 4 deletions

View File

@ -727,8 +727,7 @@ impl<'comments> Formatter<'comments> {
.append(break_("", " "))
.append(join(patterns, break_(",", ", ")))
.nest(INDENT)
.append(break_(",", ""))
.append(break_("", " "))
.append(break_(",", " "))
.append(symbol)
.append(self.case_clause_value(value))
}

View File

@ -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!(

View File

@ -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
}

View File

@ -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),