Added test
This commit is contained in:
parent
4e6001fa55
commit
cd1785b5cb
49
test/for.tm
Normal file
49
test/for.tm
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
func all_nums(nums:[Int])->Text
|
||||
result := ""
|
||||
for num in nums
|
||||
result ++= "{num},"
|
||||
else
|
||||
return "EMPTY"
|
||||
return result
|
||||
|
||||
>> all_nums([10,20,30])
|
||||
= "10,20,30,"
|
||||
>> all_nums([:Int])
|
||||
= "EMPTY"
|
||||
|
||||
func labeled_nums(nums:[Int])->Text
|
||||
result := ""
|
||||
for i,num in nums
|
||||
result ++= "{i}:{num},"
|
||||
else
|
||||
return "EMPTY"
|
||||
return result
|
||||
|
||||
>> labeled_nums([10,20,30])
|
||||
= "1:10,2:20,3:30,"
|
||||
>> labeled_nums([:Int])
|
||||
= "EMPTY"
|
||||
|
||||
func table_str(t:{Text=>Text})->Text
|
||||
str := ""
|
||||
for k,v in t
|
||||
str ++= "{k}=>{v},"
|
||||
else return "EMPTY"
|
||||
return str
|
||||
|
||||
>> t := {"key1"=>"value1", "key2"=>"value2"}
|
||||
>> table_str(t)
|
||||
= "key1=>value1,key2=>value2,"
|
||||
>> table_str({:Text=>Text})
|
||||
= "EMPTY"
|
||||
|
||||
func table_key_str(t:{Text=>Text})->Text
|
||||
str := ""
|
||||
for k in t
|
||||
str ++= "{k},"
|
||||
else return "EMPTY"
|
||||
return str
|
||||
|
||||
>> table_key_str(t)
|
||||
= "key1,key2,"
|
Loading…
Reference in New Issue
Block a user