diff options
author | Silvan Mosberger <silvan.mosberger@tweag.io> | 2023-02-01 18:27:23 +0100 |
---|---|---|
committer | Silvan Mosberger <silvan.mosberger@tweag.io> | 2024-04-22 18:33:14 +0200 |
commit | 6861ef7707a56725769594aaa725518cbe65f628 (patch) | |
tree | 62bf750df591f256dae00fdc55d7eeea72e5121d /lib/tests | |
parent | f98e5d632f974c6c966c0eb10a5ddbf067643498 (diff) |
lib.lists.ifilter0: init
Diffstat (limited to 'lib/tests')
-rw-r--r-- | lib/tests/misc.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index cf4a185c14689..6774939023d20 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -63,8 +63,10 @@ let hasAttrByPath hasInfix id + ifilter0 isStorePath lazyDerivation + length lists listToAttrs makeExtensible @@ -651,6 +653,31 @@ runTests { expected = ["b" "c"]; }; + testIfilter0Example = { + expr = ifilter0 (i: v: i == 0 || v > 2) [ 1 2 3 ]; + expected = [ 1 3 ]; + }; + testIfilter0Empty = { + expr = ifilter0 (i: v: abort "shouldn't be evaluated!") [ ]; + expected = [ ]; + }; + testIfilter0IndexOnly = { + expr = length (ifilter0 (i: v: mod i 2 == 0) [ (throw "0") (throw "1") (throw "2") (throw "3")]); + expected = 2; + }; + testIfilter0All = { + expr = ifilter0 (i: v: true) [ 10 11 12 13 14 15 ]; + expected = [ 10 11 12 13 14 15 ]; + }; + testIfilter0First = { + expr = ifilter0 (i: v: i == 0) [ 10 11 12 13 14 15 ]; + expected = [ 10 ]; + }; + testIfilter0Last = { + expr = ifilter0 (i: v: i == 5) [ 10 11 12 13 14 15 ]; + expected = [ 15 ]; + }; + testFold = let f = op: fold: fold op 0 (range 0 100); |