aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-13 13:39:44 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-13 13:39:44 -0400
commit63e6ba596ae8e35727289a69b11d5640bfc5e49e (patch)
tree2a6e3022103f42898da7c02640e2dab817b36b88 /test
parentcc0763713495a2b5b154d318772fc7f745e96635 (diff)
Change table syntax to {key:value} instead of {key=>value}
Diffstat (limited to 'test')
-rw-r--r--test/enums.tm2
-rw-r--r--test/for.tm12
-rw-r--r--test/structs.tm8
-rw-r--r--test/tables.tm34
4 files changed, 28 insertions, 28 deletions
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}