mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
add tag union closure test
This commit is contained in:
parent
342d1f34c2
commit
db05e55752
2 changed files with 66 additions and 25 deletions
46
compiler/test_mono/generated/specialize_lowlevel.txt
Normal file
46
compiler/test_mono/generated/specialize_lowlevel.txt
Normal file
|
@ -0,0 +1,46 @@
|
|||
procedure Num.24 (#Attr.2, #Attr.3):
|
||||
let Test.26 = lowlevel NumAdd #Attr.2 #Attr.3;
|
||||
ret Test.26;
|
||||
|
||||
procedure Num.26 (#Attr.2, #Attr.3):
|
||||
let Test.21 = lowlevel NumMul #Attr.2 #Attr.3;
|
||||
ret Test.21;
|
||||
|
||||
procedure Test.6 (Test.8, #Attr.12):
|
||||
let Test.4 = Index 1 #Attr.12;
|
||||
let Test.25 = CallByName Num.24 Test.8 Test.4;
|
||||
ret Test.25;
|
||||
|
||||
procedure Test.7 (Test.9, #Attr.12):
|
||||
let Test.5 = Index 1 #Attr.12;
|
||||
let Test.20 = CallByName Num.26 Test.9 Test.5;
|
||||
ret Test.20;
|
||||
|
||||
procedure Test.0 ():
|
||||
let Test.4 = 1i64;
|
||||
let Test.5 = 2i64;
|
||||
let Test.12 = 42i64;
|
||||
joinpoint Test.19 Test.13:
|
||||
let Test.14 = Index 0 Test.13;
|
||||
joinpoint Test.15 Test.11:
|
||||
ret Test.11;
|
||||
in
|
||||
switch Test.14:
|
||||
case 0:
|
||||
let Test.16 = CallByName Test.6 Test.12 Test.13;
|
||||
jump Test.15 Test.16;
|
||||
|
||||
default:
|
||||
let Test.17 = CallByName Test.7 Test.12 Test.13;
|
||||
jump Test.15 Test.17;
|
||||
|
||||
in
|
||||
let Test.24 = true;
|
||||
if Test.24 then
|
||||
let Test.28 = 0i64;
|
||||
let Test.6 = ClosureTag(Test.6) Test.28 Test.4;
|
||||
jump Test.19 Test.6;
|
||||
else
|
||||
let Test.23 = 1i64;
|
||||
let Test.7 = ClosureTag(Test.7) Test.23 Test.5;
|
||||
jump Test.19 Test.7;
|
|
@ -1057,37 +1057,32 @@ fn specialize_closures() {
|
|||
)
|
||||
}
|
||||
|
||||
// ignore doesn't seem to work with the new macro
|
||||
// #[ignore]
|
||||
// #[mono_test]
|
||||
// fn specialize_lowlevel() {
|
||||
// indoc!(
|
||||
// r#"
|
||||
// app "test" provides [ main ] to "./platform"
|
||||
#[mono_test]
|
||||
fn specialize_lowlevel() {
|
||||
indoc!(
|
||||
r#"
|
||||
app "test" provides [ main ] to "./platform"
|
||||
|
||||
// apply : (a -> a), a -> a
|
||||
// apply = \f, x -> f x
|
||||
apply : (a -> a), a -> a
|
||||
apply = \f, x -> f x
|
||||
|
||||
// main =
|
||||
// one : I64
|
||||
// one = 1
|
||||
main =
|
||||
one : I64
|
||||
one = 1
|
||||
|
||||
// two : I64
|
||||
// two = 2
|
||||
two : I64
|
||||
two = 2
|
||||
|
||||
// increment : I64 -> I64
|
||||
// increment = \x -> x + 1
|
||||
increment : I64 -> I64
|
||||
increment = \x -> x + one
|
||||
|
||||
// double : I64 -> I64
|
||||
// double = \x -> x * two
|
||||
double : I64 -> I64
|
||||
double = \x -> x * two
|
||||
|
||||
// when 3 is
|
||||
// 1 -> increment 0
|
||||
// 2 -> double 0
|
||||
// _ -> List.map [] (if True then increment else double) |> List.len
|
||||
// "#
|
||||
// )
|
||||
// }
|
||||
(if True then increment else double) 42
|
||||
"#
|
||||
)
|
||||
}
|
||||
|
||||
// #[ignore]
|
||||
// #[mono_test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue