Fix 'Pair' formatter inside forced unbroken components.
This commit is contained in:
parent
7501538053
commit
5067aad0d8
|
@ -998,14 +998,12 @@ impl<'comments> Formatter<'comments> {
|
||||||
wrap_args(elems.iter().map(|e| (self.wrap_expr(e), false))).group()
|
wrap_args(elems.iter().map(|e| (self.wrap_expr(e), false))).group()
|
||||||
}
|
}
|
||||||
|
|
||||||
UntypedExpr::Pair { fst, snd, .. } => "Pair"
|
UntypedExpr::Pair { fst, snd, .. } => {
|
||||||
|
let elems = [fst, snd];
|
||||||
|
"Pair"
|
||||||
.to_doc()
|
.to_doc()
|
||||||
.append("(")
|
.append(wrap_args(elems.iter().map(|e| (self.wrap_expr(e), false))).group())
|
||||||
.append(self.expr(fst, false))
|
}
|
||||||
.append(break_(",", ", "))
|
|
||||||
.append(self.expr(snd, false))
|
|
||||||
.append(")")
|
|
||||||
.group(),
|
|
||||||
|
|
||||||
UntypedExpr::TupleIndex { index, tuple, .. } => {
|
UntypedExpr::TupleIndex { index, tuple, .. } => {
|
||||||
let suffix = Ordinal(*index + 1).suffix().to_doc();
|
let suffix = Ordinal(*index + 1).suffix().to_doc();
|
||||||
|
|
|
@ -1116,3 +1116,27 @@ fn format_long_imports() {
|
||||||
"#
|
"#
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn format_long_pair() {
|
||||||
|
assert_format!(
|
||||||
|
r#"
|
||||||
|
test foo() {
|
||||||
|
expect(Some([
|
||||||
|
Pair(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
|
Abstain),
|
||||||
|
])) == whatever
|
||||||
|
|
||||||
|
expect(Some([
|
||||||
|
Foo(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
|
Abstain),
|
||||||
|
])) == whatever
|
||||||
|
|
||||||
|
expect(Some([
|
||||||
|
(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
|
Abstain),
|
||||||
|
])) == whatever
|
||||||
|
}
|
||||||
|
"#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
---
|
||||||
|
source: crates/aiken-lang/src/tests/format.rs
|
||||||
|
description: "Code:\n\ntest foo() {\n expect(Some([\n Pair(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },\n Abstain),\n ])) == whatever\n\n expect(Some([\n Foo(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },\n Abstain),\n ])) == whatever\n\n expect(Some([\n (GovernanceActionId { transaction: only7s, proposal_procedure: 2 },\n Abstain),\n ])) == whatever\n}\n"
|
||||||
|
---
|
||||||
|
test foo() {
|
||||||
|
expect
|
||||||
|
Some(
|
||||||
|
[
|
||||||
|
Pair(
|
||||||
|
GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
|
Abstain,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
) == whatever
|
||||||
|
|
||||||
|
expect
|
||||||
|
Some(
|
||||||
|
[
|
||||||
|
Foo(
|
||||||
|
GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
|
Abstain,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
) == whatever
|
||||||
|
|
||||||
|
expect
|
||||||
|
Some(
|
||||||
|
[
|
||||||
|
(
|
||||||
|
GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
|
Abstain,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
) == whatever
|
||||||
|
}
|
|
@ -46,10 +46,12 @@ validator {
|
||||||
expect
|
expect
|
||||||
TreasuryWithdrawal {
|
TreasuryWithdrawal {
|
||||||
beneficiaries: [
|
beneficiaries: [
|
||||||
Pair(VerificationKey(
|
Pair(
|
||||||
|
VerificationKey(
|
||||||
#"11111111111111111111111111111111111111111111111111111111",
|
#"11111111111111111111111111111111111111111111111111111111",
|
||||||
),
|
),
|
||||||
1_000_000),
|
1_000_000,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
guardrails: None,
|
guardrails: None,
|
||||||
} == action
|
} == action
|
||||||
|
|
|
@ -75,13 +75,15 @@ fn assert_inputs(inputs: List<Input>) {
|
||||||
fn assert_redeemers(redeemers: Pairs<ScriptPurpose, Data>) {
|
fn assert_redeemers(redeemers: Pairs<ScriptPurpose, Data>) {
|
||||||
expect
|
expect
|
||||||
[
|
[
|
||||||
Pair(Spend(
|
Pair(
|
||||||
|
Spend(
|
||||||
OutputReference {
|
OutputReference {
|
||||||
transaction_id: #"0000000000000000000000000000000000000000000000000000000000000000",
|
transaction_id: #"0000000000000000000000000000000000000000000000000000000000000000",
|
||||||
output_index: 0,
|
output_index: 0,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
void()),
|
void(),
|
||||||
|
),
|
||||||
] == redeemers
|
] == redeemers
|
||||||
Void
|
Void
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,18 @@ validator {
|
||||||
|
|
||||||
expect
|
expect
|
||||||
Some(
|
Some(
|
||||||
Pair(ConstitutionalCommitteeMember(VerificationKey(only0s)),
|
Pair(
|
||||||
|
ConstitutionalCommitteeMember(VerificationKey(only0s)),
|
||||||
[
|
[
|
||||||
Pair(GovernanceActionId {
|
Pair(
|
||||||
|
GovernanceActionId {
|
||||||
transaction: only9s,
|
transaction: only9s,
|
||||||
proposal_procedure: 152,
|
proposal_procedure: 152,
|
||||||
},
|
},
|
||||||
No),
|
No,
|
||||||
]),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
) == list.at(votes, 1)
|
) == list.at(votes, 1)
|
||||||
|
|
||||||
expect Some(Pair(DelegateRepresentative(Script(..)), [_, ..])) =
|
expect Some(Pair(DelegateRepresentative(Script(..)), [_, ..])) =
|
||||||
|
@ -50,15 +54,23 @@ validator {
|
||||||
|
|
||||||
expect
|
expect
|
||||||
Some(
|
Some(
|
||||||
Pair(DelegateRepresentative(VerificationKey(only0s)),
|
Pair(
|
||||||
|
DelegateRepresentative(VerificationKey(only0s)),
|
||||||
[
|
[
|
||||||
Pair(GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
Pair(
|
||||||
Abstain),
|
GovernanceActionId { transaction: only7s, proposal_procedure: 2 },
|
||||||
Pair(GovernanceActionId { transaction: only8s, proposal_procedure: 1 },
|
Abstain,
|
||||||
Abstain),
|
),
|
||||||
Pair(GovernanceActionId { transaction: only9s, proposal_procedure: 0 },
|
Pair(
|
||||||
Abstain),
|
GovernanceActionId { transaction: only8s, proposal_procedure: 1 },
|
||||||
]),
|
Abstain,
|
||||||
|
),
|
||||||
|
Pair(
|
||||||
|
GovernanceActionId { transaction: only9s, proposal_procedure: 0 },
|
||||||
|
Abstain,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
) == list.at(votes, 3)
|
) == list.at(votes, 3)
|
||||||
|
|
||||||
expect Some(Pair(StakePool(pool_id), [_, ..])) = list.at(votes, 4)
|
expect Some(Pair(StakePool(pool_id), [_, ..])) = list.at(votes, 4)
|
||||||
|
|
Loading…
Reference in New Issue