From ada24e4fd9f49f93df7245b449b00e2d1bbbec92 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Mon, 2 Sep 2024 12:17:53 -0300 Subject: [PATCH] Add mono tests for record pattern with `as` --- .../generated/as_pattern_in_closure_arg.txt | 31 +++++++++++++++++++ crates/compiler/test_mono/src/tests.rs | 13 ++++++++ 2 files changed, 44 insertions(+) create mode 100644 crates/compiler/test_mono/generated/as_pattern_in_closure_arg.txt diff --git a/crates/compiler/test_mono/generated/as_pattern_in_closure_arg.txt b/crates/compiler/test_mono/generated/as_pattern_in_closure_arg.txt new file mode 100644 index 0000000000..5d25c983bf --- /dev/null +++ b/crates/compiler/test_mono/generated/as_pattern_in_closure_arg.txt @@ -0,0 +1,31 @@ +procedure Num.19 (#Attr.2, #Attr.3): + let Num.282 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.282; + +procedure Test.1 (Test.12): + let Test.6 : I64 = StructAtIndex 0 Test.12; + let Test.5 : I64 = StructAtIndex 1 Test.12; + let Test.3 : I64 = StructAtIndex 2 Test.12; + let Test.4 : I64 = StructAtIndex 3 Test.12; + let Test.18 : I64 = CallByName Num.19 Test.3 Test.5; + let Test.19 : I64 = CallByName Num.19 Test.4 Test.6; + let Test.17 : {I64, I64} = Struct {Test.18, Test.19}; + ret Test.17; + +procedure Test.2 (Test.9): + let Test.7 : I64 = StructAtIndex 2 Test.9; + let Test.8 : I64 = StructAtIndex 3 Test.9; + let Test.16 : {I64, I64} = CallByName Test.1 Test.9; + let Test.10 : I64 = StructAtIndex 0 Test.16; + let Test.11 : I64 = StructAtIndex 1 Test.16; + let Test.15 : {I64, I64, I64, I64} = Struct {Test.7, Test.8, Test.10, Test.11}; + ret Test.15; + +procedure Test.0 (): + let Test.20 : I64 = 4i64; + let Test.21 : I64 = 3i64; + let Test.22 : I64 = 1i64; + let Test.23 : I64 = 2i64; + let Test.14 : {I64, I64, I64, I64} = Struct {Test.20, Test.21, Test.22, Test.23}; + let Test.13 : {I64, I64, I64, I64} = CallByName Test.2 Test.14; + ret Test.13; diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 0c69d37d31..8b2b2134f6 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -657,6 +657,19 @@ fn record_optional_field_function_use_default() { " } +#[mono_test] +fn as_pattern_in_closure_arg() { + r" + g = \{x, y, w, h} -> (x + w, y + h) + + f = \({ x, y } as box) -> + (right, bottom) = g box + (x, y, right, bottom) + + f { x: 1, y: 2, w: 3, h: 4 } + " +} + #[mono_test] fn quicksort_help() { // do we still need with_larger_debug_stack?