diff --git a/crates/aiken-lang/src/format.rs b/crates/aiken-lang/src/format.rs index 64ae9561..6f4850e3 100644 --- a/crates/aiken-lang/src/format.rs +++ b/crates/aiken-lang/src/format.rs @@ -843,30 +843,12 @@ impl<'comments> Formatter<'comments> { false }; - match args { - [arg] if is_breakable_expr(&arg.value) => self - .expr(fun) - .append(if needs_curly { - break_(" {", " { ") - } else { - break_("(", "(") - }) - .append(self.call_arg(arg, needs_curly)) - .append(if needs_curly { - break_("}", " }") - } else { - break_(")", ")") - }) - .group(), - - _ => self - .expr(fun) - .append(wrap_args( - args.iter() - .map(|a| (self.call_arg(a, needs_curly), needs_curly)), - )) - .group(), - } + self.expr(fun) + .append(wrap_args( + args.iter() + .map(|a| (self.call_arg(a, needs_curly), needs_curly)), + )) + .group() } pub fn if_expr<'a>( diff --git a/crates/aiken-lang/src/tests/format.rs b/crates/aiken-lang/src/tests/format.rs index d5a053f3..90257acd 100644 --- a/crates/aiken-lang/src/tests/format.rs +++ b/crates/aiken-lang/src/tests/format.rs @@ -305,3 +305,46 @@ fn test_format_bytearray_literals() { assert_fmt(src, expected); } + +#[test] +fn test_nested_function_calls() { + let src = indoc! {r#" + fn foo(output) { + [ + output.address.stake_credential == Some( + Inline( + VerificationKeyCredential( + #"66666666666666666666666666666666666666666666666666666666", + )) + ) + , + when output.datum is { + InlineDatum(_) -> True + _ -> error("expected inline datum") + }, + ] + |> list.and + } + "#}; + + let expected = indoc! {r#" + fn foo(output) { + [ + output.address.stake_credential == Some( + Inline( + VerificationKeyCredential( + #"66666666666666666666666666666666666666666666666666666666", + ), + ), + ), + when output.datum is { + InlineDatum(_) -> True + _ -> error("expected inline datum") + }, + ] + |> list.and + } + "#}; + + assert_fmt(src, expected); +} diff --git a/examples/acceptance_tests/035/lib/aiken/dict.ak b/examples/acceptance_tests/035/lib/aiken/dict.ak index a2bbcc2f..173e3bef 100644 --- a/examples/acceptance_tests/035/lib/aiken/dict.ak +++ b/examples/acceptance_tests/035/lib/aiken/dict.ak @@ -19,8 +19,8 @@ pub fn insert( value v: value, ) -> Dict { Dict { - inner: do_insert_with(self.inner, k, v, fn(_, left, _right) { Some(left) })} - + inner: do_insert_with(self.inner, k, v, fn(_, left, _right) { Some(left) }), + } } pub fn union_with( diff --git a/examples/acceptance_tests/040/lib/tests.ak b/examples/acceptance_tests/040/lib/tests.ak index 9c051f28..18bd9864 100644 --- a/examples/acceptance_tests/040/lib/tests.ak +++ b/examples/acceptance_tests/040/lib/tests.ak @@ -32,34 +32,34 @@ test expect_ford1() { owner == #"" && wheels == 4 && truck_bed_limit == 10000 } - test expect_ford2() { - let initial_car = Ford {remote_connect: #"", owner: #[34,34,34,34,34], wheels: 6, truck_bed_limit: 15000, car_doors: []} + let initial_car = + Ford { + remote_connect: #"", + owner: #"2222222222", + wheels: 6, + truck_bed_limit: 15000, + car_doors: [], + } expect Ford { owner, wheels, remote_connect, .. } = initial_car - owner == #[34,34,34,34,34] && wheels == 6 && remote_connect == #"" + owner == #"2222222222" && wheels == 6 && remote_connect == #"" } - - - test expect_list1() { - let initial_car = [5,6,7] - expect [a,b,c] = initial_car - a == 5 && b == 6 && c == 7 + let initial_car = [5, 6, 7] + expect [a, b, c] = initial_car + a == 5 && b == 6 && c == 7 } - - test expect_list2() { - let initial_car = [5,6,7] + let initial_car = [5, 6, 7] expect [a, ..d] = initial_car a == 5 && d == [6, 7] } - - test expect_list3() { - let initial_car = builtin.list_data([builtin.i_data(5), builtin.i_data(6), builtin.i_data(7)]) + let initial_car = + builtin.list_data([builtin.i_data(5), builtin.i_data(6), builtin.i_data(7)]) expect [a, ..d]: List = initial_car a == 5 && d == [6, 7] } diff --git a/examples/acceptance_tests/script_context/README.md b/examples/acceptance_tests/script_context/README.md index e49671fe..237f30f4 100644 --- a/examples/acceptance_tests/script_context/README.md +++ b/examples/acceptance_tests/script_context/README.md @@ -20,10 +20,10 @@ for convenience. ## Test Coverage - [ ] Purpose - - [x] Spend - - [x] Mint - - [x] Withdraw - - [ ] Publish + - [x] spend + - [x] mint + - [x] withdraw + - [ ] publish - [ ] Transaction - [ ] inputs @@ -35,15 +35,15 @@ for convenience. - [ ] pointer - [x] value - [x] datum - - [x] None - - [x] Hash - - [x] Inline + - [x] none + - [x] hash + - [x] inline - [x] script - - [x] None - - [x] Reference + - [x] none + - [x] reference - [x] values - - [x] Pure Ada - - [x] Native assets + - [x] pure ada + - [x] native assets - [x] fee - [x] mint - [ ] certificates diff --git a/examples/acceptance_tests/script_context/validators/deploy.ak b/examples/acceptance_tests/script_context/validators/deploy.ak index 78a27b41..c2ef8707 100644 --- a/examples/acceptance_tests/script_context/validators/deploy.ak +++ b/examples/acceptance_tests/script_context/validators/deploy.ak @@ -57,12 +57,12 @@ fn assert_first_output(output) { fn assert_second_output(output) { [ output.address.stake_credential == Some( - Inline( - VerificationKeyCredential( - #"66666666666666666666666666666666666666666666666666666666", - )) - ) - , + Inline( + VerificationKeyCredential( + #"66666666666666666666666666666666666666666666666666666666", + ), + ), + ), when output.datum is { InlineDatum(_) -> True _ -> error("expected inline datum") diff --git a/examples/acceptance_tests/script_context/validators/withdrawals.ak b/examples/acceptance_tests/script_context/validators/withdrawals.ak index 2626e440..200393e3 100644 --- a/examples/acceptance_tests/script_context/validators/withdrawals.ak +++ b/examples/acceptance_tests/script_context/validators/withdrawals.ak @@ -8,17 +8,17 @@ use aiken/transaction/credential.{ fn spend(_datum: Void, _redeemer: Void, ctx: ScriptContext) { let alice = Inline( - VerificationKeyCredential( - #"22222222222222222222222222222222222222222222222222222222", - )) - + VerificationKeyCredential( + #"22222222222222222222222222222222222222222222222222222222", + ), + ) let bob = Inline( - ScriptCredential( - #"afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72", - )) - + ScriptCredential( + #"afddc16c18e7d8de379fb9aad39b3d1b5afd27603e5ebac818432a72", + ), + ) [ when dict.get(ctx.transaction.withdrawals, alice) is {