Skip to content

Commit

Permalink
fix: unable to have newline after expect bool shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Nov 20, 2023
1 parent 2ed9178 commit abd1865
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/aiken-lang/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,6 @@ impl<'comments> Formatter<'comments> {
kind: AssignmentKind,
annotation: &'a Option<Annotation>,
) -> Document<'a> {
self.pop_empty_lines(pattern.location().end);

let keyword = match kind {
AssignmentKind::Let => "let",
AssignmentKind::Expect => "expect",
Expand All @@ -673,6 +671,8 @@ impl<'comments> Formatter<'comments> {
keyword.to_doc().append(self.case_clause_value(value))
}
_ => {
self.pop_empty_lines(pattern.location().end);

let pattern = self.pattern(pattern);

let annotation = annotation
Expand Down
13 changes: 13 additions & 0 deletions crates/aiken-lang/src/tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ fn format_grouped_expression_4() {
);
}

#[test]
fn format_preserve_newline_after_bool_expect() {
assert_format!(
r#"
fn foo() {
expect 1 == 1
False
}
"#
);
}

#[test]
fn format_validator() {
assert_format!(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
source: crates/aiken-lang/src/tests/format.rs
description: "Code:\n\nfn foo() {\n expect 1 == 1\n\n False\n}\n"
---
fn foo() {
expect 1 == 1

False
}

2 changes: 2 additions & 0 deletions examples/gift_card/validators/multi.ak
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ fn check_mint_and_outputs(
expected_assets,
fn(expected_asset) { expected_asset == minted_asset_name },
)

expect
list.any(
outputs,
Expand All @@ -132,6 +133,7 @@ fn check_mint_and_outputs(
datum == InlineDatum(minted_asset_name) && address.payment_credential == validator_cred
},
)

quantity == 1 && check_mint_and_outputs(
rest_assets,
outputs,
Expand Down

0 comments on commit abd1865

Please sign in to comment.