More tests
This commit is contained in:
parent
fa66053e13
commit
6583221c0b
26
test/minmax.tm
Normal file
26
test/minmax.tm
Normal 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
16
test/reductions.tm
Normal 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)
|
Loading…
Reference in New Issue
Block a user