diff options
Diffstat (limited to 'lib/tests/misc.nix')
-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); |