aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-06 15:11:26 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-06 15:11:26 -0400
commitfb216e955f04a803f11953be27e76bd4d2c9e76d (patch)
treede2c471c5416ec2ee490bdb33f5e3e202d94675a /test
parent73246764f88f6f652316ee0c138a990d836698a7 (diff)
Use colons instead of '=' for tables (e.g. {1: 2})
Diffstat (limited to 'test')
-rw-r--r--test/for.tm6
-rw-r--r--test/lang.tm10
-rw-r--r--test/serialization.tm4
-rw-r--r--test/structs.tm4
-rw-r--r--test/tables.tm48
-rw-r--r--test/text.tm2
6 files changed, 37 insertions, 37 deletions
diff --git a/test/for.tm b/test/for.tm
index 75ad2fee..9c329c62 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,"
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,7 +40,7 @@ func main()
>> labeled_nums([])
= "EMPTY"
- >> t := {"key1"="value1", "key2"="value2"}
+ >> t := {"key1":"value1", "key2":"value2"}
>> table_str(t)
= "key1:value1,key2:value2,"
>> table_str({})
diff --git a/test/lang.tm b/test/lang.tm
index 21b70f96..08fcb87d 100644
--- a/test/lang.tm
+++ b/test/lang.tm
@@ -2,11 +2,11 @@ lang HTML
HEADER := $HTML"<!DOCTYPE HTML>"
convert(t:Text->HTML)
t = t.translate({
- "&"="&amp;",
- "<"="&lt;",
- ">"="&gt;",
- '"'="&quot",
- "'"="&#39;",
+ "&": "&amp;",
+ "<": "&lt;",
+ ">": "&gt;",
+ '"': "&quot",
+ "'": "&#39;",
})
return HTML.from_text(t)
diff --git a/test/serialization.tm b/test/serialization.tm
index 8e1a4a1c..fd1ac743 100644
--- a/test/serialization.tm
+++ b/test/serialization.tm
@@ -43,9 +43,9 @@ func main()
assert roundtrip[] == obj[]
do
- >> obj := {"A"=10, "B"=20; fallback={"C"=30}}
+ >> obj := {"A":10, "B":20; fallback={"C":30}}
>> bytes := obj.serialized()
- >> roundtrip := deserialize(bytes -> {Text=Int})
+ >> roundtrip := deserialize(bytes -> {Text:Int})
assert roundtrip == obj
assert roundtrip.fallback == obj.fallback
diff --git a/test/structs.tm b/test/structs.tm
index 40c1b566..c7fba47e 100644
--- a/test/structs.tm
+++ b/test/structs.tm
@@ -66,9 +66,9 @@ func main()
= Password("Swordfish")
>> "$my_pass"
= "Password(...)"
- >> users_by_password := {my_pass="User1", Password("xxx")="User2"}
+ >> users_by_password := {my_pass: "User1", Password("xxx"): "User2"}
>> "$users_by_password"
- = '{Password(...)="User1", Password(...)="User2"}'
+ = '{Password(...): "User1", Password(...): "User2"}'
>> users_by_password[my_pass]!
= "User1"
diff --git a/test/tables.tm b/test/tables.tm
index 1f4244f9..60cedf4a 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -1,6 +1,6 @@
func main()
- >> t := {"one"=1, "two"=2}
- = {"one"=1, "two"=2}
+ >> t := {"one": 1, "two": 2}
+ = {"one": 1, "two": 2}
>> t["one"]
= 1?
@@ -29,8 +29,8 @@ func main()
>> t.values
= [1, 2]
- >> t2 := {"three"=3; fallback=t}
- = {"three"=3; fallback={"one"=1, "two"=2}}
+ >> t2 := {"three": 3; fallback=t}
+ = {"three": 3; fallback={"one": 1, "two": 2}}
>> t2["one"]
= 1?
@@ -42,7 +42,7 @@ func main()
>> t2.length
= 1
>> t2.fallback
- = {"one"=1, "two"=2}?
+ = {"one": 1, "two": 2}?
t2_str := ""
for k,v in t2
@@ -50,20 +50,20 @@ func main()
>> 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}
+ >> {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}
- >> t3 := @{1=10, 2=20, 3=30}
+ >> t3 := @{1: 10, 2: 20, 3: 30}
>> t3.remove(3)
>> t3[]
- = {1=10, 2=20}
+ = {1: 10, 2: 20}
do
- >> plain := {1=10, 2=20, 3=30}
+ >> plain := {1: 10, 2: 20, 3: 30}
>> plain[2]!
= 20
>> plain[2]!
@@ -75,34 +75,34 @@ func main()
>> plain.has(456)
= no
- >> fallback := {4=40; fallback=plain}
+ >> fallback := {4: 40; fallback=plain}
>> fallback.has(1)
= yes
>> fallback[1] or -999
= 10
do
- >> t4 := &{"one"= 1}
+ >> t4 := &{"one": 1}
>> t4["one"] = 999
>> t4["two"] = 222
>> t4[]
- = {"one"=999, "two"=222}
+ = {"one": 999, "two": 222}
do
- assert {1=1, 2=2} == {2=2, 1=1}
- assert {1=1, 2=2} != {1=1, 2=999}
+ assert {1: 1, 2: 2} == {2: 2, 1: 1}
+ assert {1: 1, 2: 2} != {1: 1, 2: 999}
- >> {1=1, 2=2} <> {2=2, 1=1}
+ >> {1: 1, 2: 2} <> {2: 2, 1: 1}
= Int32(0)
- >> ints : [{Int=Int}] = [{}, {0=0}, {99=99}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 2=-99, 3=3}, {1=1, 99=-99, 3=4}].sorted()
- = [{}, {0=0}, {1=1, 2=-99, 3=3}, {1=1, 2=2, 3=3}, {1=1, 99=99, 3=3}, {1=1, 99=-99, 3=4}, {99=99}]
+ >> ints : [{Int:Int}] = [{}, {0: 0}, {99: 99}, {1: 1, 2: 2, 3: 3}, {1: 1, 99: 99, 3: 3}, {1: 1, 2: -99, 3: 3}, {1: 1, 99: -99, 3: 4}].sorted()
+ = [{}, {0: 0}, {1: 1, 2: -99, 3: 3}, {1: 1, 2: 2, 3: 3}, {1: 1, 99: 99, 3: 3}, {1: 1, 99: -99, 3: 4}, {99: 99}]
>> other_ints : [|Int|] = [||, |1|, |2|, |99|, |0, 3|, |1, 2|, |99|].sorted()
= [||, |0, 3|, |1|, |1, 2|, |2|, |99|, |99|]
do
# Default values:
- counter := &{"x"=10; default=0}
+ counter := &{"x": 10; default=0}
>> counter["x"]
= 10
>> counter["y"]
@@ -115,4 +115,4 @@ func main()
>> counter["y"] += 1
>> counter
>> counter[]
- = {"x"=10, "y"=1; default=0}
+ = {"x": 10, "y": 1; default=0}
diff --git a/test/text.tm b/test/text.tm
index ff55555d..93a1f2a8 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -203,7 +203,7 @@ func main()
>> "Hello".replace("ello", "i")
= "Hi"
- >> "<tag>".translate({"<"="&lt;", ">"="&gt;"})
+ >> "<tag>".translate({"<": "&lt;", ">": "&gt;"})
= "&lt;tag&gt;"
>> "Abc".repeat(3)