1use crate::assert_js;
2
3#[test]
4fn arity_1() {
5 assert_js!(
6 r#"
7pub fn main() {
8 use <- pair()
9 123
10}
11
12fn pair(f) {
13 let x = f()
14 #(x, x)
15}
16"#,
17 )
18}
19
20#[test]
21fn arity_2() {
22 assert_js!(
23 r#"
24pub fn main() {
25 use <- pair(1.0)
26 123
27}
28
29fn pair(x, f) {
30 let y = f()
31 #(x, y)
32}
33"#,
34 )
35}
36
37#[test]
38fn arity_3() {
39 assert_js!(
40 r#"
41pub fn main() {
42 use <- trip(1.0, "")
43 123
44}
45
46fn trip(x, y, f) {
47 let z = f()
48 #(x, y, z)
49}
50"#,
51 )
52}
53
54#[test]
55fn no_callback_body() {
56 assert_js!(
57 r#"
58pub fn main() {
59 let thingy = fn(f) { f() }
60 use <- thingy()
61}
62"#
63 );
64}
65
66#[test]
67fn patterns() {
68 assert_js!(
69 r#"
70pub fn main() {
71 use Box(x) <- apply(Box(1))
72 x
73}
74
75type Box(a) {
76 Box(a)
77}
78
79fn apply(arg, fun) {
80 fun(arg)
81}
82"#
83 );
84}