aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm76
-rw-r--r--test/bytes.tm6
-rw-r--r--test/defer.tm2
-rw-r--r--test/enums.tm4
-rw-r--r--test/extern.tm2
-rw-r--r--test/integers.tm26
-rw-r--r--test/iterators.tm2
-rw-r--r--test/lambdas.tm4
-rw-r--r--test/lang.tm4
-rw-r--r--test/metamethods.tm2
-rw-r--r--test/minmax.tm2
-rw-r--r--test/nums.tm16
-rw-r--r--test/optionals.tm4
-rw-r--r--test/paths.tm62
-rw-r--r--test/reductions.tm4
-rw-r--r--test/serialization.tm30
-rw-r--r--test/sets.tm22
-rw-r--r--test/structs.tm8
-rw-r--r--test/tables.tm16
-rw-r--r--test/text.tm180
20 files changed, 236 insertions, 236 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index 4834f0ab..c60085ca 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -60,7 +60,7 @@ func main():
do:
>> arr := @[10, 20]
>> copy := arr[]
- >> arr:insert(30)
+ >> arr.insert(30)
>> arr
= @[10, 20, 30]
>> copy
@@ -72,7 +72,7 @@ func main():
do:
>> arr := &[10, 20, 30]
- >> reversed := arr:reversed()
+ >> reversed := arr.reversed()
= [30, 20, 10]
# Ensure the copy-on-write behavior triggers:
>> arr[1] = 999
@@ -82,105 +82,105 @@ func main():
do:
>> nums := @[10, -20, 30]
# Sorted function doesn't mutate original:
- >> nums:sorted()
+ >> nums.sorted()
= [-20, 10, 30]
>> nums
= @[10, -20, 30]
# Sort function does mutate in place:
- >> nums:sort()
+ >> nums.sort()
>> nums
= @[-20, 10, 30]
# Custom sort functions:
- >> nums:sort(func(x,y:&Int): x:abs() <> y:abs())
+ >> nums.sort(func(x,y:&Int): x.abs() <> y.abs())
>> nums
= @[10, -20, 30]
- >> nums:sort(func(x,y:&Int): y[] <> x[])
+ >> nums.sort(func(x,y:&Int): y[] <> x[])
>> nums
= @[30, 10, -20]
- >> ["A", "B", "C"]:sample(10, [1.0, 0.5, 0.0])
+ >> ["A", "B", "C"].sample(10, [1.0, 0.5, 0.0])
do:
>> heap := @[(i * 1337) mod 37 for i in 10]
- >> heap:heapify()
+ >> heap.heapify()
>> heap
heap_order : @[Int] = @[]
repeat:
- heap_order:insert(heap:heap_pop() or stop)
- >> heap_order[] == heap_order:sorted()
+ heap_order.insert(heap.heap_pop() or stop)
+ >> heap_order[] == heap_order.sorted()
= yes
heap_order[] = []
for i in 10:
- heap:heap_push((i*13337) mod 37)
+ heap.heap_push((i*13337) mod 37)
>> heap
repeat:
- heap_order:insert(heap:heap_pop() or stop)
- >> heap_order[] == heap_order:sorted()
+ heap_order.insert(heap.heap_pop() or stop)
+ >> heap_order[] == heap_order.sorted()
= yes
do:
- >> [i*10 for i in 5]:from(3)
+ >> [i*10 for i in 5].from(3)
= [30, 40, 50]
- >> [i*10 for i in 5]:to(3)
+ >> [i*10 for i in 5].to(3)
= [10, 20, 30]
- >> [i*10 for i in 5]:to(-2)
+ >> [i*10 for i in 5].to(-2)
= [10, 20, 30, 40]
- >> [i*10 for i in 5]:from(-2)
+ >> [i*10 for i in 5].from(-2)
= [40, 50]
- >> [i*10 for i in 5]:by(2)
+ >> [i*10 for i in 5].by(2)
= [10, 30, 50]
- >> [i*10 for i in 5]:by(-1)
+ >> [i*10 for i in 5].by(-1)
= [50, 40, 30, 20, 10]
- >> [10, 20, 30, 40]:by(2)
+ >> [10, 20, 30, 40].by(2)
= [10, 30]
- >> [10, 20, 30, 40]:by(-2)
+ >> [10, 20, 30, 40].by(-2)
= [40, 20]
- >> [i*10 for i in 10]:by(2):by(2)
+ >> [i*10 for i in 10].by(2).by(2)
= [10, 50, 90]
- >> [i*10 for i in 10]:by(2):by(-1)
+ >> [i*10 for i in 10].by(2).by(-1)
= [90, 70, 50, 30, 10]
- # Test iterating over array:from() and array:to()
+ # Test iterating over array.from() and array.to()
xs := ["A", "B", "C", "D"]
- for i,x in xs:to(-2):
- for y in xs:from(i+1):
+ for i,x in xs.to(-2):
+ for y in xs.from(i+1):
say("$(x)$(y)")
do:
>> nums := @[-7, -4, -1, 2, 5]
- >> nums:sort()
- >> [nums:binary_search(i) for i in nums[]]
+ >> nums.sort()
+ >> [nums.binary_search(i) for i in nums[]]
= [1, 2, 3, 4, 5]
- >> nums:sort(func(a,b:&Int): a:abs() <> b:abs())
- >> [nums:binary_search(i, func(a,b:&Int): a:abs() <> b:abs()) for i in nums[]]
+ >> nums.sort(func(a,b:&Int): a.abs() <> b.abs())
+ >> [nums.binary_search(i, func(a,b:&Int): a.abs() <> b.abs()) for i in nums[]]
= [1, 2, 3, 4, 5]
- >> ["a", "b", "c"]:find("b")
+ >> ["a", "b", "c"].find("b")
= 2?
- >> ["a", "b", "c"]:find("XXX")
+ >> ["a", "b", "c"].find("XXX")
= none
- >> [10, 20]:first(func(i:&Int): i:is_prime())
+ >> [10, 20].first(func(i:&Int): i.is_prime())
= none
- >> [4, 5, 6]:first(func(i:&Int): i:is_prime())
+ >> [4, 5, 6].first(func(i:&Int): i.is_prime())
= 2?
do:
>> nums := &[10, 20, 30, 40, 50]
- >> nums:pop()
+ >> nums.pop()
= 50?
>> nums
= &[10, 20, 30, 40]
- >> nums:pop(2)
+ >> nums.pop(2)
= 20?
>> nums
= &[10, 30, 40]
- >> nums:clear()
+ >> nums.clear()
>> nums
= &[]
- >> nums:pop()
+ >> nums.pop()
= none
diff --git a/test/bytes.tm b/test/bytes.tm
index a62acd10..862d2674 100644
--- a/test/bytes.tm
+++ b/test/bytes.tm
@@ -8,9 +8,9 @@ func main():
= Byte(0xFF)
>> b := Byte(0x0F)
- >> b:hex()
+ >> b.hex()
= "0F"
- >> b:hex(prefix=yes)
+ >> b.hex(prefix=yes)
= "0x0F"
- >> b:hex(uppercase=no)
+ >> b.hex(uppercase=no)
= "0f"
diff --git a/test/defer.tm b/test/defer.tm
index 6657bdc5..4053f0c1 100644
--- a/test/defer.tm
+++ b/test/defer.tm
@@ -3,7 +3,7 @@ func main():
nums : @[Int] = @[]
do:
defer:
- nums:insert(x)
+ nums.insert(x)
x = 999
>> nums
diff --git a/test/enums.tm b/test/enums.tm
index 58bc412c..19590353 100644
--- a/test/enums.tm
+++ b/test/enums.tm
@@ -43,9 +43,9 @@ func main():
>> x := Foo.One(123)
>> t := {x}
- >> t:has(x)
+ >> t.has(x)
= yes
- >> t:has(Foo.Zero)
+ >> t.has(Foo.Zero)
= no
>> choose_text(Foo.Zero)
diff --git a/test/extern.tm b/test/extern.tm
index b1f3c7f9..17c39948 100644
--- a/test/extern.tm
+++ b/test/extern.tm
@@ -1,4 +1,4 @@
-extern sqrt:func(n:Num->Num)
+extern sqrt : func(n:Num->Num)
func main():
>> sqrt(4)
diff --git a/test/integers.tm b/test/integers.tm
index 76e55ca1..508a38ae 100644
--- a/test/integers.tm
+++ b/test/integers.tm
@@ -43,11 +43,11 @@ func main():
= "1,2,3,4,5,"
>> x := Int64(123)
- >> x:format(digits=5)
+ >> x.format(digits=5)
= "00123"
- >> x:hex()
+ >> x.hex()
= "0x7B"
- >> x:octal()
+ >> x.octal()
= "0o173"
>> Int64.min
@@ -56,11 +56,11 @@ func main():
= Int64(9223372036854775807)
- >> Int32(123):hex()
+ >> Int32(123).hex()
= "0x7B"
- >> Int16(123):hex()
+ >> Int16(123).hex()
= "0x7B"
- >> Int8(123):hex()
+ >> Int8(123).hex()
= "0x7B"
>> Int(2.1, truncate=yes)
@@ -92,13 +92,13 @@ func main():
>> (n/d)*d + (n mod d) == n
= yes
- >> 0:next_prime()
+ >> (0).next_prime()
= 2
- >> 7:next_prime()
+ >> (7).next_prime()
= 11
- #>> 11:prev_prime()
+ #>> (11).prev_prime()
#= 7
- >> (and: p:is_prime() for p in [
+ >> (and: p.is_prime() for p in [
2, 3, 5, 7,
137372146048179869781170214707,
811418847921670560768224995279,
@@ -113,7 +113,7 @@ func main():
])!
= yes
- >> (or: p:is_prime() for p in [
+ >> (or: p.is_prime() for p in [
-1, 0, 1, 4, 6,
137372146048179869781170214707*2,
811418847921670560768224995279*3,
@@ -131,8 +131,8 @@ func main():
>> Int64(no)
= Int64(0)
- >> 4:choose(2)
+ >> (4).choose(2)
= 6
- >> 4:factorial()
+ >> (4).factorial()
= 24
diff --git a/test/iterators.tm b/test/iterators.tm
index a8316aba..64d21ea3 100644
--- a/test/iterators.tm
+++ b/test/iterators.tm
@@ -27,7 +27,7 @@ func main():
do:
result : @[Text] = @[]
for foo in pairwise(values):
- result:insert("$(foo.x)$(foo.y)")
+ result.insert("$(foo.x)$(foo.y)")
>> result[]
= ["AB", "BC", "CD"]
diff --git a/test/lambdas.tm b/test/lambdas.tm
index 3d536086..6e261e0f 100644
--- a/test/lambdas.tm
+++ b/test/lambdas.tm
@@ -12,7 +12,7 @@ func main():
>> add_one(10)
= 11
- >> shout := func(msg:Text): say("$(msg:upper())!")
+ >> shout := func(msg:Text): say("$(msg.upper())!")
>> shout("hello")
>> asdf := add_one
@@ -23,7 +23,7 @@ func main():
>> add_100(5)
= 105
- >> shout2 := suffix_fn(func(t:Text): t:upper(), "!")
+ >> shout2 := suffix_fn(func(t:Text): t.upper(), "!")
>> shout2("hello")
= "HELLO!"
diff --git a/test/lang.tm b/test/lang.tm
index dba096d6..6d0a94ea 100644
--- a/test/lang.tm
+++ b/test/lang.tm
@@ -1,7 +1,7 @@
lang HTML:
HEADER := $HTML"<!DOCTYPE HTML>"
convert(t:Text->HTML):
- t = t:translate({
+ t = t.translate({
"&"="&amp;",
"<"="&lt;",
">"="&gt;",
@@ -43,7 +43,7 @@ func main():
>> $HTML"$(Int8(3))"
= $HTML"3"
- >> html:paragraph()
+ >> html.paragraph()
= $HTML"<p>Hello I &lt;3 hax!</p>"
>> Text(html)
diff --git a/test/metamethods.tm b/test/metamethods.tm
index 5566b4e9..aac37c4b 100644
--- a/test/metamethods.tm
+++ b/test/metamethods.tm
@@ -53,7 +53,7 @@ func main():
= Vec2(x=-90, y=-180)
>> x * y
= Vec2(x=1000, y=4000)
- >> x:dot(y)
+ >> x.dot(y)
= 5000
>> x * -1
= Vec2(x=-10, y=-20)
diff --git a/test/minmax.tm b/test/minmax.tm
index f28aec91..a0f0640f 100644
--- a/test/minmax.tm
+++ b/test/minmax.tm
@@ -18,7 +18,7 @@ func main():
>> Foo(999, 1) _min_.y Foo(1, 10)
= Foo(x=999, y=1)
- >> Foo(-999, -999) _max_:len() Foo(10, 10)
+ >> Foo(-999, -999) _max_.len() Foo(10, 10)
= Foo(x=-999, y=-999)
diff --git a/test/nums.tm b/test/nums.tm
index 285614d9..e5de1e22 100644
--- a/test/nums.tm
+++ b/test/nums.tm
@@ -14,12 +14,12 @@ func main():
>> Num.PI
= 3.141592653589793
- >> Num.PI:format(precision=10)
+ >> Num.PI.format(precision=10)
= "3.1415926536"
>> Num.INF
= Num.INF
- >> Num.INF:isinf()
+ >> Num.INF.isinf()
= yes
>> none_num : Num? = none
@@ -53,24 +53,24 @@ func main():
# >> 0./0.
# = none
- >> Num.PI:cos()!:near(-1)
+ >> Num.PI.cos()!.near(-1)
= yes
- >> Num.PI:sin()!:near(0)
+ >> Num.PI.sin()!.near(0)
= yes
- >> Num.INF:near(-Num.INF)
+ >> Num.INF.near(-Num.INF)
= no
>> Num32.sqrt(16)
= Num32(4)?
- >> 0.25:mix(10, 20)
+ >> (0.25).mix(10, 20)
= 12.5
- >> 2.0:mix(10, 20)
+ >> (2.0).mix(10, 20)
= 30.
>> Num(5)
= 5.
- >> 0.5:percent()
+ >> (0.5).percent()
= "50%"
diff --git a/test/optionals.tm b/test/optionals.tm
index 316b2e71..bf3e1633 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -57,7 +57,7 @@ func maybe_lambda(should_i:Bool-> func()?):
func maybe_c_string(should_i:Bool->CString?):
if should_i:
- return ("hi":as_c_string())?
+ return ("hi".as_c_string())?
else:
return none
@@ -248,7 +248,7 @@ func main():
>> nones : {Int?} = {none, none}
>> also_nones : {Int?} = {none}
>> nones == also_nones
- >> [5?, none, none, 6?]:sorted()
+ >> [5?, none, none, 6?].sorted()
= [none, none, 5, 6]
do:
diff --git a/test/paths.tm b/test/paths.tm
index e448dee1..85f9b191 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -1,8 +1,8 @@
# Tests for file paths
func main():
- >> (/):exists()
+ >> (/).exists()
= yes
- >> (~/):exists()
+ >> (~/).exists()
= yes
>> (~/Downloads/file(1).txt)
@@ -12,73 +12,73 @@ func main():
= (/half\)paren)
>> filename := "example.txt"
- >> (~):child(filename)
+ >> (~).child(filename)
= (~/example.txt)
- >> tmpdir := (/tmp/tomo-test-path-XXXXXX):unique_directory()
- >> (/tmp):subdirectories():has(tmpdir)
+ >> tmpdir := (/tmp/tomo-test-path-XXXXXX).unique_directory()
+ >> (/tmp).subdirectories().has(tmpdir)
= yes
>> tmpfile := (tmpdir++(./one.txt))
- >> tmpfile:write("Hello world")
- >> tmpfile:append("!")
- >> tmpfile:read()
+ >> tmpfile.write("Hello world")
+ >> tmpfile.append("!")
+ >> tmpfile.read()
= "Hello world!"?
- >> tmpfile:read_bytes()!
+ >> tmpfile.read_bytes()!
= [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21]
- >> tmpdir:files():has(tmpfile)
+ >> tmpdir.files().has(tmpfile)
= yes
- if tmp_lines := tmpfile:by_line():
+ if tmp_lines := tmpfile.by_line():
>> [line for line in tmp_lines]
= ["Hello world!"]
else:
fail("Couldn't read lines in $tmpfile")
- >> (./does-not-exist.xxx):read()
+ >> (./does-not-exist.xxx).read()
= none
- >> (./does-not-exist.xxx):read_bytes()
+ >> (./does-not-exist.xxx).read_bytes()
= none
- if lines := (./does-not-exist.xxx):by_line():
+ if lines := (./does-not-exist.xxx).by_line():
fail("I could read lines in a nonexistent file")
else:
pass
- >> tmpfile:remove()
+ >> tmpfile.remove()
- >> tmpdir:files():has(tmpfile)
+ >> tmpdir.files().has(tmpfile)
= no
- >> tmpdir:remove()
+ >> tmpdir.remove()
>> p := (/foo/baz.x/qux.tar.gz)
- >> p:base_name()
+ >> p.base_name()
= "qux.tar.gz"
- >> p:parent()
+ >> p.parent()
= (/foo/baz.x)
- >> p:extension()
+ >> p.extension()
= "tar.gz"
- >> p:extension(full=no)
+ >> p.extension(full=no)
= "gz"
- >> (~/.foo):extension()
+ >> (~/.foo).extension()
= ""
- >> (~/foo):extension()
+ >> (~/foo).extension()
= ""
- >> (~/.foo.baz.qux):extension()
+ >> (~/.foo.baz.qux).extension()
= "baz.qux"
- >> (/):parent()
+ >> (/).parent()
= (/)
- >> (~/x/.):parent()
+ >> (~/x/.).parent()
= (~)
- >> (~/x):parent()
+ >> (~/x).parent()
= (~)
- >> (.):parent()
+ >> (.).parent()
= (..)
- >> (..):parent()
+ >> (..).parent()
= (../..)
- >> (../foo):parent()
+ >> (../foo).parent()
= (..)
# Concatenation tests:
@@ -127,4 +127,4 @@ func main():
= (/foo/bar/quux)
say("Globbing:")
- >> (./*.tm):glob()
+ >> (./*.tm).glob()
diff --git a/test/reductions.tm b/test/reductions.tm
index f2fa4b9c..bd74f306 100644
--- a/test/reductions.tm
+++ b/test/reductions.tm
@@ -17,14 +17,14 @@ func main():
>> (_max_: [3, 5, 2, 1, 4])
= 5?
- >> (_max_:abs(): [1, -10, 5])
+ >> (_max_.abs(): [1, -10, 5])
= -10?
>> (_max_: [Foo(0, 0), Foo(1, 0), Foo(0, 10)])!
= Foo(x=1, y=0)
>> (_max_.y: [Foo(0, 0), Foo(1, 0), Foo(0, 10)])!
= Foo(x=0, y=10)
- >> (_max_.y:abs(): [Foo(0, 0), Foo(1, 0), Foo(0, 10), Foo(0, -999)])!
+ >> (_max_.y.abs(): [Foo(0, 0), Foo(1, 0), Foo(0, 10), Foo(0, -999)])!
= Foo(x=0, y=-999)
say("(or) and (and) have early out behavior:")
diff --git a/test/serialization.tm b/test/serialization.tm
index 9e3ac368..b3ccc67a 100644
--- a/test/serialization.tm
+++ b/test/serialization.tm
@@ -6,44 +6,44 @@ enum MyEnum(Zero, One(x:Int), Two(x:Num, y:Text))
func main():
do:
>> obj := Int64(123)
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Int64) == obj
= yes
do:
>> obj := 5
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Int) == obj
= yes
do:
>> obj := 9999999999999999999999999999999999999999999999999999
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Int) == obj
= yes
do:
>> obj := "Héllo"
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Text)
>> deserialize(bytes -> Text) == obj
= yes
do:
- >> obj := [Int64(10), Int64(20), Int64(30)]:reversed()
- >> bytes := obj:serialized()
+ >> obj := [Int64(10), Int64(20), Int64(30)].reversed()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> [Int64]) == obj
= yes
do:
>> obj := yes
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Bool) == obj
= yes
do:
>> obj := @[10, 20]
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> roundtrip := deserialize(bytes -> @[Int])
>> roundtrip == obj
= no
@@ -52,44 +52,44 @@ func main():
do:
>> obj := {"A"=10, "B"=20; fallback={"C"=30}}
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> {Text=Int}) == obj
= yes
do:
>> obj := @Foo("root")
>> obj.next = @Foo("abcdef", next=obj)
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> @Foo)
# = @Foo(name="root", next=@Foo(name="abcdef", next=@~1))
do:
>> obj := MyEnum.Two(123, "OKAY")
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> MyEnum) == obj
= yes
do:
>> obj := "Hello"?
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Text?) == obj
= yes
do:
>> obj := {10, 20, 30}
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> {Int}) == obj
= yes
do:
>> obj : Num? = none
- >> bytes := obj:serialized()
+ >> bytes := obj.serialized()
>> deserialize(bytes -> Num?) == obj
= yes
do:
cases := [0, -1, 1, 10, 100000, 999999999999999999999999999]
for i in cases:
- >> bytes := i:serialized()
+ >> bytes := i.serialized()
>> deserialize(bytes -> Int) == i
= yes
diff --git a/test/sets.tm b/test/sets.tm
index 7b285d60..5179947e 100644
--- a/test/sets.tm
+++ b/test/sets.tm
@@ -2,36 +2,36 @@
func main():
>> t1 := @{10, 20, 30, 10}
= @{10, 20, 30}
- >> t1:has(10)
+ >> t1.has(10)
= yes
- >> t1:has(-999)
+ >> t1.has(-999)
= no
>> t2 := {30, 40}
- >> t1:with(t2)
+ >> t1.with(t2)
>> {10, 20, 30, 40}
- >> t1:without(t2)
+ >> t1.without(t2)
>> {10, 20}
- >> t1:overlap(t2)
+ >> t1.overlap(t2)
>> {30}
- >> {1,2}:is_subset_of({2,3})
+ >> {1,2}.is_subset_of({2,3})
= no
- >> {1,2}:is_subset_of({1,2,3})
+ >> {1,2}.is_subset_of({1,2,3})
= yes
- >> {1,2}:is_subset_of({1,2})
+ >> {1,2}.is_subset_of({1,2})
= yes
- >> {1,2}:is_subset_of({1,2}, strict=yes)
+ >> {1,2}.is_subset_of({1,2}, strict=yes)
= no
- >> t1:add_all(t2)
+ >> t1.add_all(t2)
>> t1
= @{10, 20, 30, 40}
- >> t1:remove_all(t2)
+ >> t1.remove_all(t2)
>> t1
= @{10, 20}
diff --git a/test/structs.tm b/test/structs.tm
index c1d2f7b0..cf7b6a1c 100644
--- a/test/structs.tm
+++ b/test/structs.tm
@@ -33,9 +33,9 @@ func test_metamethods():
>> x < Pair(11, 20)
= yes
>> set := {x}
- >> set:has(x)
+ >> set.has(x)
= yes
- >> set:has(y)
+ >> set.has(y)
= no
func test_mixed():
@@ -50,9 +50,9 @@ func test_mixed():
>> x < Mixed(11, "Hello")
= yes
>> set := {x}
- >> set:has(x)
+ >> set.has(x)
= yes
- >> set:has(y)
+ >> set.has(y)
= no
func test_text():
diff --git a/test/tables.tm b/test/tables.tm
index 20d76269..a5f51520 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -58,7 +58,7 @@ func main():
= {2=20, 3=30, 4=40}
>> t3 := @{1=10, 2=20, 3=30}
- >> t3:remove(3)
+ >> t3.remove(3)
>> t3
= @{1=10, 2=20}
@@ -70,13 +70,13 @@ func main():
= 20
>> plain[456] or -999
= -999
- >> plain:has(2)
+ >> plain.has(2)
= yes
- >> plain:has(456)
+ >> plain.has(456)
= no
>> fallback := {4=40; fallback=plain}
- >> fallback:has(1)
+ >> fallback.has(1)
= yes
>> fallback[1] or -999
= 10
@@ -96,10 +96,10 @@ func main():
>> {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()
+ >> 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()
+ >> other_ints : [{Int}] = [{/}, {1}, {2}, {99}, {0, 3}, {1, 2}, {99}].sorted()
= [{/}, {0, 3}, {1}, {1, 2}, {2}, {99}, {99}]
do:
@@ -109,9 +109,9 @@ func main():
= 10
>> counter["y"]
= 0
- >> counter:has("x")
+ >> counter.has("x")
= yes
- >> counter:has("y")
+ >> counter.has("y")
= no
>> counter["y"] += 1
diff --git a/test/text.tm b/test/text.tm
index df48470e..b353aa26 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -2,33 +2,33 @@ func main():
str := "Hello Amélie!"
say("Testing strings like $str")
- >> str:upper()
+ >> str.upper()
= "HELLO AMÉLIE!"
- >> str:lower()
+ >> str.lower()
= "hello amélie!"
- >> str:lower():title()
+ >> str.lower().title()
= "Hello Amélie!"
>> str[1]
= "H"
- >> "I":lower()
+ >> "I".lower()
= "i"
- >> "I":lower(language="tr_TR")
+ >> "I".lower(language="tr_TR")
= "ı"
- >> "i":upper()
+ >> "i".upper()
= "I"
- >> "i":upper(language="tr_TR")
+ >> "i".upper(language="tr_TR")
= "İ"
- >> "ian":title()
+ >> "ian".title()
= "Ian"
- >> "ian":title(language="tr_TR")
+ >> "ian".title(language="tr_TR")
= "İan"
- >> "I":caseless_equals("ı")
+ >> "I".caseless_equals("ı")
= no
- >> "I":caseless_equals("ı", language="tr_TR")
+ >> "I".caseless_equals("ı", language="tr_TR")
= yes
>> str[9]
@@ -40,7 +40,7 @@ func main():
>> \U65\U301
= "é"
- >> \{Penguin}:codepoint_names()
+ >> \{Penguin}.codepoint_names()
= ["PENGUIN"]
>> \[31;1]
@@ -50,11 +50,11 @@ func main():
= yes
amelie := "Am$(\UE9)lie"
- >> amelie:split()
+ >> amelie.split()
= ["A", "m", "é", "l", "i", "e"]
- >> amelie:utf32_codepoints()
+ >> amelie.utf32_codepoints()
= [65, 109, 233, 108, 105, 101]
- >> amelie:bytes()
+ >> amelie.bytes()
= [0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
>> Text.from_bytes([0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65])!
= "Amélie"
@@ -62,36 +62,36 @@ func main():
= none
amelie2 := "Am$(\U65\U301)lie"
- >> amelie2:split()
+ >> amelie2.split()
= ["A", "m", "é", "l", "i", "e"]
- >> amelie2:utf32_codepoints()
+ >> amelie2.utf32_codepoints()
= [65, 109, 233, 108, 105, 101]
- >> amelie2:bytes()
+ >> amelie2.bytes()
= [0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
- >> amelie:codepoint_names()
+ >> amelie.codepoint_names()
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"]
- >> amelie2:codepoint_names()
+ >> amelie2.codepoint_names()
= ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"]
- >> "Hello":replace("e", "X")
+ >> "Hello".replace("e", "X")
= "HXllo"
- >> "Hello":has("l")
+ >> "Hello".has("l")
= yes
- >> "Hello":has("x")
+ >> "Hello".has("x")
= no
- >> "Hello":replace("l", "")
+ >> "Hello".replace("l", "")
= "Heo"
- >> "xxxx":replace("x", "")
+ >> "xxxx".replace("x", "")
= ""
- >> "xxxx":replace("y", "")
+ >> "xxxx".replace("y", "")
= "xxxx"
- >> "One two three four five six":replace("e ", "")
+ >> "One two three four five six".replace("e ", "")
= "Ontwo threfour fivsix"
- >> amelie:has(amelie2)
+ >> amelie.has(amelie2)
= yes
>> multiline := "
@@ -118,135 +118,135 @@ func main():
= "one {nested} two 3"
c := "É̩"
- >> c:codepoint_names()
+ >> c.codepoint_names()
= ["LATIN CAPITAL LETTER E WITH ACUTE", "COMBINING VERTICAL LINE BELOW"]
- >> c == Text.from_codepoint_names(c:codepoint_names())!
+ >> c == Text.from_codepoint_names(c.codepoint_names())!
= yes
- >> c == Text.from_codepoints(c:utf32_codepoints())
+ >> c == Text.from_codepoints(c.utf32_codepoints())
= yes
- >> c == Text.from_bytes(c:bytes())!
+ >> c == Text.from_bytes(c.bytes())!
= yes
- >> "one$(\n)two$(\n)three":lines()
+ >> "one$(\n)two$(\n)three".lines()
= ["one", "two", "three"]
- >> "one$(\n)two$(\n)three$(\n)":lines()
+ >> "one$(\n)two$(\n)three$(\n)".lines()
= ["one", "two", "three"]
- >> "one$(\n)two$(\n)three$(\n\n)":lines()
+ >> "one$(\n)two$(\n)three$(\n\n)".lines()
= ["one", "two", "three", ""]
- >> "one$(\r\n)two$(\r\n)three$(\r\n)":lines()
+ >> "one$(\r\n)two$(\r\n)three$(\r\n)".lines()
= ["one", "two", "three"]
- >> "":lines()
+ >> "".lines()
= []
say("Test splitting and joining text:")
- >> "one,, two,three":split(",")
+ >> "one,, two,three".split(",")
= ["one", "", " two", "three"]
- >> [t for t in "one,, two,three":by_split(",")]
+ >> [t for t in "one,, two,three".by_split(",")]
= ["one", "", " two", "three"]
- >> "one,, two,three":split_any(", ")
+ >> "one,, two,three".split_any(", ")
= ["one", "two", "three"]
- >> [t for t in "one,, two,three":by_split_any(", ")]
+ >> [t for t in "one,, two,three".by_split_any(", ")]
= ["one", "two", "three"]
- >> ",one,, two,three,":split(",")
+ >> ",one,, two,three,".split(",")
= ["", "one", "", " two", "three", ""]
- >> [t for t in ",one,, two,three,":by_split(",")]
+ >> [t for t in ",one,, two,three,".by_split(",")]
= ["", "one", "", " two", "three", ""]
- >> ",one,, two,three,":split_any(", ")
+ >> ",one,, two,three,".split_any(", ")
= ["", "one", "two", "three", ""]
- >> [t for t in ",one,, two,three,":by_split_any(", ")]
+ >> [t for t in ",one,, two,three,".by_split_any(", ")]
= ["", "one", "two", "three", ""]
- >> "abc":split()
+ >> "abc".split()
= ["a", "b", "c"]
- >> "one two three":split_any()
+ >> "one two three".split_any()
= ["one", "two", "three"]
- >> ", ":join(["one", "two", "three"])
+ >> ", ".join(["one", "two", "three"])
= "one, two, three"
- >> "":join(["one", "two", "three"])
+ >> "".join(["one", "two", "three"])
= "onetwothree"
- >> "+":join(["one"])
+ >> "+".join(["one"])
= "one"
- >> "+":join([])
+ >> "+".join([])
= ""
- >> "":split()
+ >> "".split()
= []
say("Test text slicing:")
- >> "abcdef":slice()
+ >> "abcdef".slice()
= "abcdef"
- >> "abcdef":slice(from=3)
+ >> "abcdef".slice(from=3)
= "cdef"
- >> "abcdef":slice(to=-2)
+ >> "abcdef".slice(to=-2)
= "abcde"
- >> "abcdef":slice(from=2, to=4)
+ >> "abcdef".slice(from=2, to=4)
= "bcd"
- >> "abcdef":slice(from=5, to=1)
+ >> "abcdef".slice(from=5, to=1)
= ""
>> house := "家"
= "家"
>> house.length
= 1
- >> house:codepoint_names()
+ >> house.codepoint_names()
= ["CJK Unified Ideographs-5BB6"]
- >> house:utf32_codepoints()
+ >> house.utf32_codepoints()
= [23478]
- >> "🐧":codepoint_names()
+ >> "🐧".codepoint_names()
= ["PENGUIN"]
>> Text.from_codepoint_names(["not a valid name here buddy"])
= none
- >> "Hello":replace("ello", "i")
+ >> "Hello".replace("ello", "i")
= "Hi"
- >> "<tag>":translate({"<"="&lt;", ">"="&gt;"})
+ >> "<tag>".translate({"<"="&lt;", ">"="&gt;"})
= "&lt;tag&gt;"
- >> "Abc":repeat(3)
+ >> "Abc".repeat(3)
= "AbcAbcAbc"
- >> "abcde":starts_with("ab")
+ >> "abcde".starts_with("ab")
= yes
- >> "abcde":starts_with("bc")
+ >> "abcde".starts_with("bc")
= no
- >> "abcde":ends_with("de")
+ >> "abcde".ends_with("de")
= yes
- >> "abcde":starts_with("cd")
+ >> "abcde".starts_with("cd")
= no
- >> "abcde":without_prefix("ab")
+ >> "abcde".without_prefix("ab")
= "cde"
- >> "abcde":without_suffix("ab")
+ >> "abcde".without_suffix("ab")
= "abcde"
- >> "abcde":without_prefix("de")
+ >> "abcde".without_prefix("de")
= "abcde"
- >> "abcde":without_suffix("de")
+ >> "abcde".without_suffix("de")
= "abc"
- >> ("hello" ++ " " ++ "Amélie"):reversed()
+ >> ("hello" ++ " " ++ "Amélie").reversed()
= "eilémA olleh"
do:
say("Testing concatenation-stability:")
ab := Text.from_codepoint_names(["LATIN SMALL LETTER E", "COMBINING VERTICAL LINE BELOW"])!
- >> ab:codepoint_names()
+ >> ab.codepoint_names()
= ["LATIN SMALL LETTER E", "COMBINING VERTICAL LINE BELOW"]
>> ab.length
= 1
a := Text.from_codepoint_names(["LATIN SMALL LETTER E"])!
b := Text.from_codepoint_names(["COMBINING VERTICAL LINE BELOW"])!
- >> (a++b):codepoint_names()
+ >> (a++b).codepoint_names()
= ["LATIN SMALL LETTER E", "COMBINING VERTICAL LINE BELOW"]
>> (a++b) == ab
= yes
@@ -279,38 +279,38 @@ func main():
>> concat4 == final
= yes
- >> "x":left_pad(5)
+ >> "x".left_pad(5)
= " x"
- >> "x":right_pad(5)
+ >> "x".right_pad(5)
= "x "
- >> "x":middle_pad(5)
+ >> "x".middle_pad(5)
= " x "
- >> "1234":left_pad(8, "XYZ")
+ >> "1234".left_pad(8, "XYZ")
= "XYZX1234"
- >> "1234":right_pad(8, "XYZ")
+ >> "1234".right_pad(8, "XYZ")
= "1234XYZX"
- >> "1234":middle_pad(9, "XYZ")
+ >> "1234".middle_pad(9, "XYZ")
= "XY1234XYZ"
- >> amelie:width()
+ >> amelie.width()
= 6
cowboy := "🤠"
- >> cowboy:width()
+ >> cowboy.width()
= 2
- >> cowboy:left_pad(4)
+ >> cowboy.left_pad(4)
= " 🤠"
- >> cowboy:right_pad(4)
+ >> cowboy.right_pad(4)
= "🤠 "
- >> cowboy:middle_pad(4)
+ >> cowboy.middle_pad(4)
= " 🤠 "
- >> " one, ":trim(" ,")
+ >> " one, ".trim(" ,")
= "one"
- >> " one, ":trim(" ,", left=no)
+ >> " one, ".trim(" ,", left=no)
= " one"
- >> " one, ":trim(" ,", right=no)
+ >> " one, ".trim(" ,", right=no)
= "one, "
- >> " ":trim(" ,")
+ >> " ".trim(" ,")
= ""
- >> " ":trim(" ,", left=no)
+ >> " ".trim(" ,", left=no)
= ""