From cd1785b5cb4e432dc0f1bb4148517fd0f8d8de84 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 7 Mar 2024 12:07:14 -0500 Subject: Added test --- test/for.tm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/for.tm (limited to 'test/for.tm') diff --git a/test/for.tm b/test/for.tm new file mode 100644 index 00000000..05990d37 --- /dev/null +++ b/test/for.tm @@ -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," -- cgit v1.2.3