fix: unable to have newline after expect bool shortcut

This commit is contained in:
rvcas 2023-11-18 17:45:41 -05:00 committed by Lucas
parent 2ed91780f4
commit abd18656e3
4 changed files with 27 additions and 2 deletions

View File

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

View File

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

View File

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

View File

@ -124,6 +124,7 @@ fn check_mint_and_outputs(
expected_assets,
fn(expected_asset) { expected_asset == minted_asset_name },
)
expect
list.any(
outputs,
@ -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,