aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-04 17:06:09 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-04 17:06:09 -0400
commit0b8074154e2671691050bdb3bcb33245625a056c (patch)
tree1410e0c4e05c6372e876cd08f16d117e12868f41 /test
parentfadcb45baf1274e06cfe37b87655b9146aa52874 (diff)
First working compile of refactor to add explicit typing to declarations
and support untyped empty collections and `none`s
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm10
-rw-r--r--test/defer.tm2
-rw-r--r--test/for.tm6
-rw-r--r--test/import.tm4
-rw-r--r--test/iterators.tm2
-rw-r--r--test/optionals.tm4
-rw-r--r--test/paths.tm2
-rw-r--r--test/reductions.tm7
-rw-r--r--test/tables.tm8
-rw-r--r--test/text.tm18
10 files changed, 32 insertions, 31 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index 66819a74..5816c359 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -1,7 +1,7 @@
func main():
do:
- >> [:Num32]
- = [:Num32]
+ >> nums : [Num32] = []
+ = []
do:
>> arr := [10, 20, 30]
@@ -104,7 +104,7 @@ func main():
>> heap := @[(i * 1337) mod 37 for i in 10]
>> heap:heapify()
>> heap
- sorted := @[:Int]
+ sorted : @[Int] = @[]
repeat:
sorted:insert(heap:heap_pop() or stop)
>> sorted == sorted:sorted()
@@ -112,7 +112,7 @@ func main():
for i in 10:
heap:heap_push((i*13337) mod 37)
>> heap
- sorted = @[:Int]
+ sorted = @[]
repeat:
sorted:insert(heap:heap_pop() or stop)
>> sorted == sorted:sorted()
@@ -181,6 +181,6 @@ func main():
= &[10, 30, 40]
>> nums:clear()
>> nums
- = &[:Int]
+ = &[]
>> nums:pop()
= none:Int
diff --git a/test/defer.tm b/test/defer.tm
index 911ed672..6657bdc5 100644
--- a/test/defer.tm
+++ b/test/defer.tm
@@ -1,6 +1,6 @@
func main():
x := 123
- nums := @[:Int]
+ nums : @[Int] = @[]
do:
defer:
nums:insert(x)
diff --git a/test/for.tm b/test/for.tm
index a67e9d5d..e4967e86 100644
--- a/test/for.tm
+++ b/test/for.tm
@@ -32,18 +32,18 @@ func table_key_str(t:{Text=Text} -> Text):
func main():
>> all_nums([10,20,30])
= "10,20,30,"
- >> all_nums([:Int])
+ >> all_nums([])
= "EMPTY"
>> labeled_nums([10,20,30])
= "1:10,2:20,3:30,"
- >> labeled_nums([:Int])
+ >> labeled_nums([])
= "EMPTY"
>> t := {"key1"="value1", "key2"="value2"}
>> table_str(t)
= "key1:value1,key2:value2,"
- >> table_str({:Text=Text})
+ >> table_str({})
= "EMPTY"
>> table_key_str(t)
diff --git a/test/import.tm b/test/import.tm
index a7b198b9..960bfcbb 100644
--- a/test/import.tm
+++ b/test/import.tm
@@ -8,11 +8,11 @@ func returns_imported_type(->ImportedType):
return get_value() # Imported from ./use_import.tm
func main():
- >> [:vectors.Vec2]
+ >> empty : [vectors.Vec2] = []
>> returns_vec()
= Vec2(x=1, y=2)
- >> [:ImportedType]
+ >> imported : [ImportedType] = []
>> returns_imported_type()
= ImportedType("Hello")
diff --git a/test/iterators.tm b/test/iterators.tm
index 4a85e6f9..0b6c2a89 100644
--- a/test/iterators.tm
+++ b/test/iterators.tm
@@ -25,7 +25,7 @@ func main():
= ["AB", "BC", "CD"]
do:
- result := @[:Text]
+ result : @[Text] = @[]
for foo in pairwise(values):
result:insert("$(foo.x)$(foo.y)")
>> result[]
diff --git a/test/optionals.tm b/test/optionals.tm
index 02817441..a1b0dcd6 100644
--- a/test/optionals.tm
+++ b/test/optionals.tm
@@ -247,8 +247,8 @@ func main():
= yes
>> {none:Int, none:Int}
= {none:Int}
- >> {:Int? none, none}
- = {none:Int}
+ >> nones : {Int?} = {none, none}
+ = {none}
>> [5?, none:Int, none:Int, 6?]:sorted()
= [none:Int, none:Int, 5, 6]
diff --git a/test/paths.tm b/test/paths.tm
index f224b0ff..4f053485 100644
--- a/test/paths.tm
+++ b/test/paths.tm
@@ -25,7 +25,7 @@ func main():
>> tmpfile:read()
= "Hello world!"?
>> tmpfile:read_bytes()
- = [:Byte, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21]?
+ = [0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x21]?
>> tmpdir:files():has(tmpfile)
= yes
diff --git a/test/reductions.tm b/test/reductions.tm
index 840a3b3c..4f33bb20 100644
--- a/test/reductions.tm
+++ b/test/reductions.tm
@@ -4,13 +4,14 @@ func main():
>> (+: [10, 20, 30])
= 60?
- >> (+: [:Int])
+ >> empty_ints : [Int] = []
+ >> (+: empty_ints)
= none : Int
>> (+: [10, 20, 30]) or 0
= 60
- >> (+: [:Int]) or 0
+ >> (+: empty_ints) or 0
= 0
>> (_max_: [3, 5, 2, 1, 4])
@@ -36,7 +37,7 @@ func main():
>> (<=: [1, 2, 2, 3, 4])!
= yes
- >> (<=: [:Int])
+ >> (<=: empty_ints)
= none : Bool
>> (<=: [5, 4, 3, 2, 1])!
diff --git a/test/tables.tm b/test/tables.tm
index 140fd1cf..144b93e5 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -96,11 +96,11 @@ func main():
>> {1=1, 2=2} <> {2=2, 1=1}
= Int32(0)
- >> [{: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()
- = [{:Int=Int}, {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}]
- >> [{:Int}, {1}, {2}, {99}, {0, 3}, {1, 2}, {99}]:sorted()
- = [{:Int}, {0, 3}, {1}, {1, 2}, {2}, {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:
diff --git a/test/text.tm b/test/text.tm
index fe295f9c..ae91050f 100644
--- a/test/text.tm
+++ b/test/text.tm
@@ -53,10 +53,10 @@ func main():
>> amelie:split()
= ["A", "m", "é", "l", "i", "e"]
>> amelie:utf32_codepoints()
- = [:Int32, 65, 109, 233, 108, 105, 101]
+ = [65, 109, 233, 108, 105, 101]
>> amelie:bytes()
- = [:Byte, 0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
- >> Text.from_bytes([:Byte 0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65])!
+ = [0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
+ >> Text.from_bytes([0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65])!
= "Amélie"
>> Text.from_bytes([Byte(0xFF)])
= none:Text
@@ -65,9 +65,9 @@ func main():
>> amelie2:split()
= ["A", "m", "é", "l", "i", "e"]
>> amelie2:utf32_codepoints()
- = [:Int32, 65, 109, 233, 108, 105, 101]
+ = [65, 109, 233, 108, 105, 101]
>> amelie2:bytes()
- = [:Byte, 0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
+ = [0x41, 0x6D, 0xC3, 0xA9, 0x6C, 0x69, 0x65]
>> 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"]
@@ -136,7 +136,7 @@ func main():
>> "one$(\r\n)two$(\r\n)three$(\r\n)":lines()
= ["one", "two", "three"]
>> "":lines()
- = [:Text]
+ = []
!! Test splitting and joining text:
>> "one,, two,three":split(",")
@@ -171,11 +171,11 @@ func main():
>> "+":join(["one"])
= "one"
- >> "+":join([:Text])
+ >> "+":join([])
= ""
>> "":split()
- = [:Text]
+ = []
!! Test text slicing:
>> "abcdef":slice()
@@ -196,7 +196,7 @@ func main():
>> house:codepoint_names()
= ["CJK Unified Ideographs-5BB6"]
>> house:utf32_codepoints()
- = [:Int32, 23478]
+ = [23478]
>> "🐧":codepoint_names()
= ["PENGUIN"]