From 63e6ba596ae8e35727289a69b11d5640bfc5e49e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 13 Apr 2024 13:39:44 -0400 Subject: Change table syntax to {key:value} instead of {key=>value} --- test/enums.tm | 2 +- test/for.tm | 12 ++++++------ test/structs.tm | 8 ++++---- test/tables.tm | 34 +++++++++++++++++----------------- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'test') diff --git a/test/enums.tm b/test/enums.tm index f321af8c..c06862a3 100644 --- a/test/enums.tm +++ b/test/enums.tm @@ -21,7 +21,7 @@ func main() = yes >> x := Foo.One(123) - >> t := {x=>"found"; default="missing"} + >> t := {x:"found"; default="missing"} >> t[x] = "found" >> t[Foo.Zero] diff --git a/test/for.tm b/test/for.tm index 51940973..63656380 100644 --- a/test/for.tm +++ b/test/for.tm @@ -15,14 +15,14 @@ func labeled_nums(nums:[Int])->Text return "EMPTY" return result -func table_str(t:{Text=>Text})->Text +func table_str(t:{Text:Text})->Text str := "" for k,v in t - str ++= "{k}=>{v}," + str ++= "{k}:{v}," else return "EMPTY" return str -func table_key_str(t:{Text=>Text})->Text +func table_key_str(t:{Text:Text})->Text str := "" for k in t str ++= "{k}," @@ -40,10 +40,10 @@ func main() >> labeled_nums([:Int]) = "EMPTY" - >> t := {"key1"=>"value1", "key2"=>"value2"} + >> t := {"key1":"value1", "key2":"value2"} >> table_str(t) - = "key1=>value1,key2=>value2," - >> table_str({:Text=>Text}) + = "key1:value1,key2:value2," + >> table_str({:Text:Text}) = "EMPTY" >> table_key_str(t) diff --git a/test/structs.tm b/test/structs.tm index 1d9de8d0..9fe2f6a7 100644 --- a/test/structs.tm +++ b/test/structs.tm @@ -26,7 +26,7 @@ func test_metamethods() >> x < Pair(11, 20) = yes - >> t2 := {x=> "found"; default="missing"} + >> t2 := {x:"found"; default="missing"} >> t2[x] = "found" >> t2[y] @@ -43,7 +43,7 @@ func test_mixed() = no >> x < Mixed(11, "Hello") = yes - >> t := {x=> "found"; default="missing"} + >> t := {x:"found"; default="missing"} >> t[x] = "found" >> t[y] @@ -58,8 +58,8 @@ func main() >> my_pass := Password("Swordfish") = Password(...) - >> users_by_password := {my_pass=> "User1", Password("xxx")=>"User2"} - = {Password(...)=>"User1", Password(...)=>"User2"} + >> users_by_password := {my_pass:"User1", Password("xxx"):"User2"} + = {Password(...):"User1", Password(...):"User2"} >> users_by_password[my_pass] = "User1" diff --git a/test/tables.tm b/test/tables.tm index a55e4238..2ba42714 100644 --- a/test/tables.tm +++ b/test/tables.tm @@ -1,6 +1,6 @@ func main() - >> t := {"one"=>1, "two"=>2; default=999} - = {"one"=>1, "two"=>2; default=999} + >> t := {"one":1, "two":2; default=999} + = {"one":1, "two":2; default=999} >> t["one"] = 1 @@ -11,24 +11,24 @@ func main() t_str := "" for k,v in t - t_str ++= "({k}=>{v})" + t_str ++= "({k}:{v})" >> t_str - = "(one=>1)(two=>2)" + = "(one:1)(two:2)" >> #t = 2 >> t.default = ?%999 >> t.fallback - = !{Text=>Int} + = !{Text:Int} >> t.keys = ["one", "two"] >> t.values = [1, 2] - >> t2 := {"three"=>3; fallback=t} - = {"three"=>3; fallback={"one"=>1, "two"=>2; default=999}} + >> t2 := {"three":3; fallback=t} + = {"three":3; fallback={"one":1, "two":2; default=999}} >> t2["one"] = 1 @@ -42,17 +42,17 @@ func main() >> t2.default = !Int >> t2.fallback - = ?%{"one"=>1, "two"=>2; default=999} + = ?%{"one":1, "two":2; default=999} t2_str := "" for k,v in t2 - t2_str ++= "({k}=>{v})" + t2_str ++= "({k}:{v})" >> t2_str - = "(three=>3)" - - >> {i=>10*i for i in 5} - = {1=>10, 2=>20, 3=>30, 4=>40, 5=>50} - >> {i=>10*i for i in 5 if i mod 2 != 0} - = {1=>10, 3=>30, 5=>50} - >> {x=>10*x for x in y if x > 1 for y in [3, 4, 5] if y < 5} - = {2=>20, 3=>30, 4=>40} + = "(three:3)" + + >> {i:10*i for i in 5} + = {1:10, 2:20, 3:30, 4:40, 5:50} + >> {i:10*i for i in 5 if i mod 2 != 0} + = {1:10, 3:30, 5:50} + >> {x:10*x for x in y if x > 1 for y in [3, 4, 5] if y < 5} + = {2:20, 3:30, 4:40} -- cgit v1.2.3