aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-09 17:26:01 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-09 17:26:01 -0500
commit145a078387b8bce5e8e3c93c333c030aa7455e4c (patch)
tree48e113e07888a546bdf9543db2a19587aeef3071 /test
parent8dd51a113ead1fe88c80af9165219ca5398715f6 (diff)
Make the compiler stricter about not promoting local value variables to
pointers
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm22
-rw-r--r--test/iterators.tm4
-rw-r--r--test/sets.tm8
-rw-r--r--test/tables.tm4
4 files changed, 19 insertions, 19 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index 7f1882ab..7fa1ef62 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -84,31 +84,31 @@ func main():
= [30, 20, 10]
do:
- >> nums := [10, -20, 30]
+ >> nums := @[10, -20, 30]
# Sorted function doesn't mutate original:
>> nums:sorted()
= [-20, 10, 30]
>> nums
- = [10, -20, 30]
+ = @[10, -20, 30]
# Sort function does mutate in place:
>> nums:sort()
>> nums
- = [-20, 10, 30]
+ = @[-20, 10, 30]
# Custom sort functions:
>> nums:sort(func(x,y:&Int): x:abs() <> y:abs())
>> nums
- = [10, -20, 30]
+ = @[10, -20, 30]
>> nums:sort(func(x,y:&Int): y[] <> x[])
>> nums
- = [30, 10, -20]
+ = @[30, 10, -20]
>> ["A", "B", "C"]:sample(10, [1.0, 0.5, 0.0])
do:
- >> heap := [random:int(1, 50) for _ in 10]
+ >> heap := @[random:int(1, 50) for _ in 10]
>> heap:heapify()
>> heap
- sorted := [:Int]
+ sorted := @[:Int]
while heap.length > 0:
sorted:insert(heap:heap_pop())
>> sorted == sorted:sorted()
@@ -116,7 +116,7 @@ func main():
for _ in 10:
heap:heap_push(random:int(1, 50))
>> heap
- sorted = [:Int]
+ sorted = @[:Int]
while heap.length > 0:
sorted:insert(heap:heap_pop())
>> sorted == sorted:sorted()
@@ -155,12 +155,12 @@ func main():
say("$(x)$(y)")
do:
- >> nums := [-7, -4, -1, 2, 5]
+ >> nums := @[-7, -4, -1, 2, 5]
>> nums:sort()
- >> [nums:binary_search(i) for i in nums]
+ >> [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: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")
diff --git a/test/iterators.tm b/test/iterators.tm
index d6bcfa13..2adcab4a 100644
--- a/test/iterators.tm
+++ b/test/iterators.tm
@@ -25,10 +25,10 @@ func main():
= ["AB", "BC", "CD"]
do:
- result := [:Text]
+ result := @[:Text]
for foo in pairwise(values):
result:insert("$(foo.x)$(foo.y)")
- >> result
+ >> result[]
= ["AB", "BC", "CD"]
>> [i for i in range(5, 10)]
diff --git a/test/sets.tm b/test/sets.tm
index a6a9d57b..7b285d60 100644
--- a/test/sets.tm
+++ b/test/sets.tm
@@ -1,7 +1,7 @@
func main():
- >> t1 := {10, 20, 30, 10}
- = {10, 20, 30}
+ >> t1 := @{10, 20, 30, 10}
+ = @{10, 20, 30}
>> t1:has(10)
= yes
>> t1:has(-999)
@@ -30,10 +30,10 @@ func main():
>> t1:add_all(t2)
>> t1
- = {10, 20, 30, 40}
+ = @{10, 20, 30, 40}
>> t1:remove_all(t2)
>> t1
- = {10, 20}
+ = @{10, 20}
>> {3, i for i in 5}
= {3, 1, 2, 4, 5}
diff --git a/test/tables.tm b/test/tables.tm
index 3dd27b0f..650e4e18 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -57,10 +57,10 @@ func main():
>> {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}