summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorUrban Müller2020-05-25 18:10:12 +0200
committerUrban Müller2020-05-25 18:10:12 +0200
commit93bf725ddad4afa053f41c886735208ce3c39b2d (patch)
tree5ec84598972fee879bd77c453e234e230eb29fa9 /test
parentf031e08bc3c1b829e294a5499c4176bd65850340 (diff)
downloaditools-93bf725ddad4afa053f41c886735208ce3c39b2d.tar.gz
itools-93bf725ddad4afa053f41c886735208ce3c39b2d.tar.bz2
itools-93bf725ddad4afa053f41c886735208ce3c39b2d.zip
test new sort features
Diffstat (limited to 'test')
-rwxr-xr-xtest/it.t5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/it.t b/test/it.t
index 65adcd6..64b0fac 100755
--- a/test/it.t
+++ b/test/it.t
@@ -435,6 +435,11 @@ is(it::json_decode('{"foo":"bar"}', ['assoc' => true])['foo'], "bar");
is(it::sort(["2!","19!","1!"]), ["1!", "19!", "2!"]);
is(it::sort(["2!","19!","1!"], "r"), ["2!", "19!", "1!"]);
is(it::sort(["2!","19!","1!"], "rn"), ["19!", "2!", "1!"]);
+is(it::sort(["ccc", "b", "aa"], "", function ($a, $b) { return strlen($a) <=> strlen($b); }), ["b", "aa", "ccc"]);
+is(it::sort(["ccc", "b", "aa"], function ($a, $b) { return strlen($a) <=> strlen($b); }), ["b", "aa", "ccc"]);
+is(it::sort(["ccc", "b", "aa"], "a", function ($a, $b) { return strlen($a) <=> strlen($b); }), [1 => "b", 2 => "aa", 0 => "ccc"]);
+is(it::sort(["ccc" => 2, "b" => 3, "aa" => 1], "k", function ($a, $b) { return strlen($a) <=> strlen($b); }), ['b' => 3, 'aa' => 1, 'ccc' => 2]);
+is(it::sort(["ccc", "b", "aa"], "strlen"), ["b", "aa", "ccc"]);
is(it::mod(-9, 4), 3);
is(it::mod(-8, 4), 0);