mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Add mono tests for opaque pattern with as
This commit is contained in:
parent
ada24e4fd9
commit
e2bd31a549
3 changed files with 51 additions and 4 deletions
18
crates/compiler/test_mono/generated/opaque_as_pattern_in_closure_arg.txt
generated
Normal file
18
crates/compiler/test_mono/generated/opaque_as_pattern_in_closure_arg.txt
generated
Normal file
|
@ -0,0 +1,18 @@
|
|||
procedure Num.21 (#Attr.2, #Attr.3):
|
||||
let Num.281 : U64 = lowlevel NumMul #Attr.2 #Attr.3;
|
||||
ret Num.281;
|
||||
|
||||
procedure Test.2 (Test.8):
|
||||
let Test.14 : U64 = 2i64;
|
||||
let Test.13 : U64 = CallByName Num.21 Test.8 Test.14;
|
||||
ret Test.13;
|
||||
|
||||
procedure Test.3 (Test.7):
|
||||
let Test.12 : U64 = CallByName Test.2 Test.7;
|
||||
let Test.11 : {U64, U64} = Struct {Test.7, Test.12};
|
||||
ret Test.11;
|
||||
|
||||
procedure Test.0 ():
|
||||
let Test.10 : U64 = 42i64;
|
||||
let Test.9 : {U64, U64} = CallByName Test.3 Test.10;
|
||||
ret Test.9;
|
17
crates/compiler/test_mono/generated/record_as_pattern_in_closure_arg.txt
generated
Normal file
17
crates/compiler/test_mono/generated/record_as_pattern_in_closure_arg.txt
generated
Normal file
|
@ -0,0 +1,17 @@
|
|||
procedure Test.2 (Test.9):
|
||||
let Test.7 : I64 = StructAtIndex 2 Test.9;
|
||||
let Test.8 : I64 = StructAtIndex 3 Test.9;
|
||||
let Test.17 : {I64, I64, I64, I64} = CallByName Test.2 Test.9;
|
||||
let Test.10 : I64 = StructAtIndex 0 Test.17;
|
||||
let Test.11 : I64 = StructAtIndex 1 Test.17;
|
||||
let Test.16 : {I64, I64, I64, I64} = Struct {Test.7, Test.8, Test.10, Test.11};
|
||||
ret Test.16;
|
||||
|
||||
procedure Test.0 ():
|
||||
let Test.18 : I64 = 4i64;
|
||||
let Test.19 : I64 = 3i64;
|
||||
let Test.20 : I64 = 1i64;
|
||||
let Test.21 : I64 = 2i64;
|
||||
let Test.14 : {I64, I64, I64, I64} = Struct {Test.18, Test.19, Test.20, Test.21};
|
||||
let Test.13 : {I64, I64, I64, I64} = CallByName Test.2 Test.14;
|
||||
ret Test.13;
|
|
@ -658,15 +658,27 @@ fn record_optional_field_function_use_default() {
|
|||
}
|
||||
|
||||
#[mono_test]
|
||||
fn as_pattern_in_closure_arg() {
|
||||
fn record_as_pattern_in_closure_arg() {
|
||||
r"
|
||||
g = \{x, y, w, h} -> (x + w, y + h)
|
||||
f = \{x, y, w, h} -> (x + w, y + h)
|
||||
|
||||
f = \({ x, y } as box) ->
|
||||
g = \({ x, y } as box) ->
|
||||
(right, bottom) = g box
|
||||
(x, y, right, bottom)
|
||||
|
||||
f { x: 1, y: 2, w: 3, h: 4 }
|
||||
g { x: 1, y: 2, w: 3, h: 4 }
|
||||
"
|
||||
}
|
||||
|
||||
#[mono_test]
|
||||
fn opaque_as_pattern_in_closure_arg() {
|
||||
r"
|
||||
Opaque := U64
|
||||
|
||||
f = \(@Opaque x) -> x * 2
|
||||
g = \(@Opaque x as s) -> (x, f s)
|
||||
|
||||
g (@Opaque 42)
|
||||
"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue