aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-02 13:08:06 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-02 13:08:06 -0400
commitc73e96ff916209d74e2be9bd7d8de3758685ce4d (patch)
tree8f902fea5b6790061e48600243f0f8faeded32dd /test
parentb6534ce34706d1a98584e5f916107d91da072346 (diff)
Add comparison operator <> and array method to sort by a custom
comparison function
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm12
-rw-r--r--test/tables.tm4
2 files changed, 14 insertions, 2 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index e8856b3b..d4dd2119 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -73,3 +73,15 @@ if yes
>> arr := [10, 20, 30]
>> arr:reversed()
= [30, 20, 10]
+
+if yes
+ >> nums := [10, -20, 30]
+ >> nums:sort()
+ >> nums
+ = [-20, 10, 30]
+ >> nums:sort(func(x:&%Int,y:&%Int) x:abs() <> y:abs())
+ >> nums
+ = [10, -20, 30]
+ >> nums:sort(func(x:&%Int,y:&%Int) y[] <> x[])
+ >> nums
+ = [30, 10, -20]
diff --git a/test/tables.tm b/test/tables.tm
index 53e81d48..74123f88 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -18,7 +18,7 @@ for k,v in t
>> #t
= 2
>> t.default
-= ?(readonly)999
+= ?%999
>> t.fallback
= !{Text=>Int}
@@ -42,7 +42,7 @@ for k,v in t
>> t2.default
= !Int
>> t2.fallback
-= ?(readonly){"one"=>1, "two"=>2; default=999}
+= ?%{"one"=>1, "two"=>2; default=999}
t2_str := ""
for k,v in t2