From 93bf725ddad4afa053f41c886735208ce3c39b2d Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 25 May 2020 18:10:12 +0200 Subject: test new sort features --- test/it.t | 5 +++++ 1 file changed, 5 insertions(+) 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); -- cgit v1.2.3