4 struct Mixed(x:Int, text:Text)
5 struct LinkedList(x:Int, next:@LinkedList?=none)
6 struct Password(text:Text; secret)
8 struct CorecursiveA(other:@CorecursiveB?)
9 struct CorecursiveB(other:@CorecursiveA?=none)
12 assert Single(123) == Single(123)
14 assert x == Pair(x=10, y=20)
16 assert y == Pair(x=10, y=20)
18 assert x != Pair(-1, -2)
20 func test_metamethods()
22 >> y := Pair(100, 200)
24 assert x == Pair(10, 20)
25 assert x != Pair(10, 30)
27 assert x < Pair(11, 20)
29 assert set.has(x) == yes
30 assert set.has(y) == no
33 >> x := Mixed(10, "Hello")
34 >> y := Mixed(99, "Hello")
36 assert x == Mixed(10, "Hello")
37 assert x != Mixed(10, "Bye")
38 assert x < Mixed(11, "Hello")
40 assert set.has(x) == yes
41 assert set.has(y) == no
44 >> b := @CorecursiveB()
45 >> a := @CorecursiveA(b)
48 # = @CorecursiveA(@CorecursiveB(@~1))
56 >> @LinkedList(10, @LinkedList(20))
58 >> my_pass := Password("Swordfish")
59 assert my_pass == Password("Swordfish")
60 assert "$my_pass" == "Password(...)"
61 >> users_by_password := {my_pass: "User1", Password("xxx"): "User2"}
62 assert "$users_by_password" == '{Password(...): "User1", Password(...): "User2"}'
63 assert users_by_password[my_pass]! == "User1"
65 >> CorecursiveA(@CorecursiveB())