aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fun.tdy
blob: 8b94cad3a150528a4f3552e0918250ed37e073fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Simplest
f := fn {
    print 1
}
f() <=> true

// Simple
f2 := fn a: int {
    print a
}
f2(2) <=> true

// Return value
f3 := fn -> int {
    ret 3
}
print f3()
f3() <=> 3

// Empty function
f4 := fn {}
print f4
print f4()

// Multiple arguments
adder := fn a: int, b: int -> int {
    ret a + b
}
adder(1, 2) <=> 3

// Passing functions
h := fn {
    print "h"
    ret 1
}

g := fn f: int {
    ret f()
}

g(h) <=> 1