tomo/test/enums.tm

35 lines
446 B
Plaintext
Raw Normal View History

2024-02-24 12:24:44 -08:00
enum Foo(Zero, One(x:Int), Two(x,y:Int))
>> Foo.Zero
2024-03-17 19:17:21 -07:00
= Foo.Zero
2024-03-03 10:38:27 -08:00
>> Foo.One(123)
2024-02-24 12:27:27 -08:00
= Foo.One(x=123)
2024-03-03 10:38:27 -08:00
>> Foo.Two(123, 456)
2024-02-24 12:27:27 -08:00
= Foo.Two(x=123, y=456)
2024-03-03 10:38:27 -08:00
>> Foo.One(10) == Foo.One(10)
2024-02-24 12:27:27 -08:00
= yes
>> Foo.One(10) == Foo.Zero
2024-02-24 12:27:27 -08:00
= no
2024-03-03 10:38:27 -08:00
>> Foo.One(10) == Foo.One(-1)
2024-02-24 12:27:27 -08:00
= no
2024-03-03 10:38:27 -08:00
>> Foo.One(10) < Foo.Two(1, 2)
2024-02-24 12:27:27 -08:00
= yes
2024-02-24 12:32:55 -08:00
2024-03-03 10:38:27 -08:00
>> x := Foo.One(123)
2024-02-24 12:32:55 -08:00
>> t := {x=>"found"; default="missing"}
>> t[x]
= "found"
>> t[Foo.Zero]
2024-02-24 12:32:55 -08:00
= "missing"
2024-03-17 18:48:53 -07:00
when x is o:One
>> o.x
= 123
else
fail("Oops")