1234567891011121314151617181920 | def foo(x:Int, y:Int, z:Int):String
return "$x,$y,$z"
def check(given:String,correct:String)
fail "$given is not $correct" unless given == correct
say "Test: $given ok"
check foo(1,2,3), "1,2,3"
check foo(z=1,2,3), "2,3,1"
check foo(1,z=2,3), "1,3,2"
check foo(y=1,z=2,3), "3,1,2"
check foo(x=3,y=2,z=1), "3,2,1"
def optional_args(a:Int, b:Int?, c:Num?):String
return "a=$a b=$b c=$c"
check optional_args(1), "a=1 b=nil c=nil"
check optional_args(1,2), "a=1 b=2 c=nil"
check optional_args(1,c=2.), "a=1 b=nil c=2"
check optional_args(a=1), "a=1 b=nil c=nil"
|