diff options
author | Urban Müller | 2020-05-25 18:10:12 +0200 |
---|---|---|
committer | Urban Müller | 2020-05-25 18:10:12 +0200 |
commit | 93bf725ddad4afa053f41c886735208ce3c39b2d (patch) | |
tree | 5ec84598972fee879bd77c453e234e230eb29fa9 /test/it.t | |
parent | f031e08bc3c1b829e294a5499c4176bd65850340 (diff) | |
download | itools-93bf725ddad4afa053f41c886735208ce3c39b2d.tar.gz itools-93bf725ddad4afa053f41c886735208ce3c39b2d.tar.bz2 itools-93bf725ddad4afa053f41c886735208ce3c39b2d.zip |
test new sort features
Diffstat (limited to 'test/it.t')
-rwxr-xr-x | test/it.t | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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); |