move pattern desugar tests to test_mono

This commit is contained in:
Elias Mulhall 2023-11-26 20:14:32 -05:00
parent d924125e6d
commit 0ccc71389a
No known key found for this signature in database
GPG key ID: 8D1F3C219EAB45F2
5 changed files with 79 additions and 48 deletions

View file

@ -1231,54 +1231,6 @@ mod test_can {
assert_eq!(problems, Vec::new());
}
#[test]
fn optional_field_with_binary_op() {
let src = indoc!(
r#"
{ bar ? 1 + 1 } = {}
bar
"#
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
assert_eq!(problems, Vec::new());
}
#[test]
fn nested_optional_field_with_binary_op() {
let src = indoc!(
r#"
when { x: ([{}], "foo") } is
{ x: ([{ bar ? 1 + 1 }], _) } -> bar
"#
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
assert_eq!(problems, Vec::new());
}
#[test]
fn multiline_record_pattern() {
let src = indoc!(
r#"
x = { a: 1, b: 2, c: 3 }
{
a,
b,
c,
} = x
a + b + c
"#
);
let arena = Bump::new();
let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src);
assert_eq!(problems, Vec::new());
}
#[test]
fn issue_2534() {
let src = indoc!(

View file

@ -0,0 +1,15 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.292 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.292;
procedure Test.0 ():
let Test.7 : I64 = 1i64;
let Test.8 : I64 = 2i64;
let Test.9 : I64 = 3i64;
let Test.1 : {I64, I64, I64} = Struct {Test.7, Test.8, Test.9};
let Test.2 : I64 = StructAtIndex 0 Test.1;
let Test.3 : I64 = StructAtIndex 1 Test.1;
let Test.4 : I64 = StructAtIndex 2 Test.1;
let Test.6 : I64 = CallByName Num.19 Test.2 Test.3;
let Test.5 : I64 = CallByName Num.19 Test.6 Test.4;
ret Test.5;

View file

@ -0,0 +1,23 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.291 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.291;
procedure Test.0 ():
let Test.17 : {} = Struct {};
let Test.15 : List {} = Array [Test.17];
let Test.16 : Str = "foo";
let Test.14 : {List {}, Str} = Struct {Test.15, Test.16};
let Test.10 : List {} = StructAtIndex 0 Test.14;
dec Test.16;
let Test.11 : U64 = lowlevel ListLen Test.10;
dec Test.10;
let Test.12 : U64 = 1i64;
let Test.13 : Int1 = lowlevel Eq Test.11 Test.12;
if Test.13 then
let Test.5 : I64 = 1i64;
let Test.6 : I64 = 1i64;
let Test.2 : I64 = CallByName Num.19 Test.5 Test.6;
ret Test.2;
else
let Test.7 : I64 = 0i64;
ret Test.7;

View file

@ -0,0 +1,10 @@
procedure Num.19 (#Attr.2, #Attr.3):
let Num.291 : I64 = lowlevel NumAdd #Attr.2 #Attr.3;
ret Num.291;
procedure Test.0 ():
let Test.5 : {} = Struct {};
let Test.3 : I64 = 1i64;
let Test.4 : I64 = 1i64;
let Test.1 : I64 = CallByName Num.19 Test.3 Test.4;
ret Test.1;

View file

@ -893,6 +893,37 @@ fn optional_when() {
"#
}
#[mono_test]
fn optional_field_with_binary_op() {
r#"
{ bar ? 1 + 1 } = {}
bar
"#
}
#[mono_test]
fn nested_optional_field_with_binary_op() {
r#"
when { x: ([{}], "foo") } is
{ x: ([{ bar ? 1 + 1 }], _) } -> bar
_ -> 0
"#
}
#[mono_test]
fn multiline_record_pattern() {
r#"
x = { a: 1, b: 2, c: 3 }
{
a,
b,
c,
} = x
a + b + c
"#
}
#[mono_test]
fn nested_pattern_match() {
r#"