More tests

This commit is contained in:
Bruce Hill 2024-03-07 12:18:01 -05:00
parent fa66053e13
commit 6583221c0b
2 changed files with 42 additions and 0 deletions

26
test/minmax.tm Normal file
View File

@ -0,0 +1,26 @@
>> 3 _min_ 5
= 3
>> 5 _min_ 3
= 3
struct Foo(x:Int, y:Int)
func len(f:Foo)->Num
return Num.sqrt(f.x*f.x + f.y*f.y)
>> Foo(5, 1) _min_ Foo(5, 999)
= Foo(x=5, y=1)
>> Foo(5, 999) _min_.x Foo(5, 1)
= Foo(x=5, y=999)
>> Foo(999, 1) _min_.y Foo(1, 10)
= Foo(x=999, y=1)
>> Foo(-999, -999) _max_:len() Foo(10, 10)
= Foo(x=-999, y=-999)
>> foos := [Foo(5, 1), Foo(5, 99), Foo(-999, -999)]
>> (_max_) foos
= Foo(x=5, y=99)

16
test/reductions.tm Normal file
View File

@ -0,0 +1,16 @@
>> (+) [10, 20, 30]
= 60
>> (_max_) [3, 5, 2, 1, 4]
= 5
>> (_max_:abs()) [1, -10, 5]
= -10
struct Foo(x,y:Int)
>> (_max_) [Foo(0, 0), Foo(1, 0), Foo(0, 10)]
= Foo(x=1, y=0)
>> (_max_.y) [Foo(0, 0), Foo(1, 0), Foo(0, 10)]
= Foo(x=0, y=10)
>> (_max_.y:abs()) [Foo(0, 0), Foo(1, 0), Foo(0, 10), Foo(0, -999)]
= Foo(x=0, y=-999)