blob: bf874482027f38b0cebfd18a77a219d1c00453ec (
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
|
(test "printing integers" : Int : 37 "37")
(test "printing integers" : Int : -37 "-37")
(test "printing characters" : Char : 'a' "'a'")
(data Tuple (a b) (
(Tuple a b)))
(test "printing tuples" : Tuple Int Int : (Tuple 1 2) "(1,2)")
(fun id ((x : Int)) : Int :
x)
(fun const ((x : Int) (y : Int)) : Int :
x)
(fun tuple ((x : Int) (y : Int)) : Tuple Int Int :
Tuple x y)
(fun swapped_tuple ((x : Int) (y : Int)) : Tuple Int Int :
Tuple y x)
(test "function application (id)" : Int : (id 1) "1")
(test "function application (id)" : Int : (id (id 2)) "2")
(test "function application (id)" : Int : (id (id (id 3))) "3")
(test "function application (const)" : Int : (const 1 2) "1")
(test "function application (const)" : Int : (const (const 1 2) 3) "1")
(test "function application (const)" : Int : (const 1 (const 2 3)) "1")
(test "function application (tuple)" : Tuple Int Int : (tuple 10 20) "(10,20)")
(test "function application (swapped_tuple)" : Tuple Int Int : (swapped_tuple 10 20) "(20,10)")
(fun swap ((t : Tuple Int Int)) : Tuple Int Int :
case t (
(Tuple x y -> Tuple y x)))
(test "pattern matching (tuple)" : Tuple Int Int : (swap (Tuple 1 2)) "(2,1)")
|