test: check and format tests for logical op chain

This commit is contained in:
rvcas 2023-08-14 22:05:48 -04:00 committed by Lucas
parent e14d51600f
commit 0ff64e3bac
3 changed files with 45 additions and 0 deletions

View File

@ -661,6 +661,27 @@ fn expect_sugar_incorrect_type() {
)) ))
} }
#[test]
fn logical_op_chain_expressions_should_be_bool() {
let source_code = r#"
fn foo() {
and {
1 == 1,
False,
or {
2 == 3,
1
}
}
}
"#;
assert!(matches!(
check(parse(source_code)),
Err((_, Error::CouldNotUnify { .. }))
))
}
#[test] #[test]
fn anonymous_function_scoping() { fn anonymous_function_scoping() {
let source_code = r#" let source_code = r#"

View File

@ -20,6 +20,15 @@ fn format_simple_module() {
); );
} }
#[test]
fn format_logical_op_chain() {
assert_format!(
r#"
fn smth() { and { foo, bar, or { bar, foo }} }
"#
);
}
#[test] #[test]
fn format_if() { fn format_if() {
assert_format!( assert_format!(

View File

@ -0,0 +1,15 @@
---
source: crates/aiken-lang/src/tests/format.rs
description: "Code:\n\nfn smth() { and { foo, bar, or { bar, foo }} }\n"
---
fn smth() {
and {
foo,
bar,
or {
bar,
foo,
},
}
}