Fix formatting of long multiline if/is expressions.
This commit is contained in:
parent
12c0d0bc04
commit
47a15cf8b2
|
@ -10,6 +10,7 @@
|
|||
|
||||
- **aiken-project**: Fix documentation link-tree generation messing up with modules when re-inserting the same module. @KtorZ
|
||||
- **aiken-lang**: Fix formatter adding extra unnecessary newlines after literal lists clause values or assignments. @KtorZ
|
||||
- **aiken0lang**: Fix formatting of long multi-line if/is expressions. @KtorZ
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -1323,10 +1323,7 @@ impl<'comments> Formatter<'comments> {
|
|||
.group()
|
||||
};
|
||||
|
||||
break_("", " ")
|
||||
.append("is")
|
||||
.append(break_("", " "))
|
||||
.append(is)
|
||||
break_("", " ").append("is ").append(is)
|
||||
}
|
||||
None => nil(),
|
||||
})
|
||||
|
|
|
@ -3264,3 +3264,15 @@ fn constant_usage() {
|
|||
}] if name == "some_string_constant"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wrong_arity_on_known_builtin() {
|
||||
let source_code = r#"
|
||||
const foo: Option<Int> = Some()
|
||||
"#;
|
||||
|
||||
assert!(matches!(
|
||||
check_validator(parse(source_code)),
|
||||
Err((_, Error::IncorrectFunctionCallArity { .. }))
|
||||
))
|
||||
}
|
||||
|
|
|
@ -1388,3 +1388,35 @@ fn callback_and_op() {
|
|||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiline_if_is() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn foo() {
|
||||
if first_asset
|
||||
is
|
||||
Pair(first_asset_policy, first_asset_tokens): Pair<PolicyId, Data> {
|
||||
True
|
||||
} else {
|
||||
False }
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiline_if_is_2() {
|
||||
assert_format!(
|
||||
r#"
|
||||
fn foo() {
|
||||
if [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
|
||||
is
|
||||
Pair(first_asset_policy, first_asset_tokens): Pair<PolicyId, Data> {
|
||||
True
|
||||
} else {
|
||||
False }
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn foo() {\n if first_asset\n is\n Pair(first_asset_policy, first_asset_tokens): Pair<PolicyId, Data> {\n True\n } else {\n False }\n}\n"
|
||||
---
|
||||
fn foo() {
|
||||
if first_asset
|
||||
is Pair(first_asset_policy, first_asset_tokens): Pair<PolicyId, Data> {
|
||||
True
|
||||
} else {
|
||||
False
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\nfn foo() {\n if [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n is\n Pair(first_asset_policy, first_asset_tokens): Pair<PolicyId, Data> {\n True\n } else {\n False }\n}\n"
|
||||
---
|
||||
fn foo() {
|
||||
if [
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6,
|
||||
7, 8, 9, 0,
|
||||
]
|
||||
is Pair(first_asset_policy, first_asset_tokens): Pair<PolicyId, Data> {
|
||||
True
|
||||
} else {
|
||||
False
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue