From c96e90782541f68f98aacc602181c457796b406d Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 3 Jan 2025 12:03:33 +0100 Subject: [PATCH] lib/tests/misc: Test lib.drop --- lib/tests/misc.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index f0c4b6f2c5e1c..330891f312235 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -854,6 +854,18 @@ runTests { ([ 1 2 3 ] == (take 4 [ 1 2 3 ])) ]; + testDrop = let inherit (lib) drop; in testAllTrue [ + # list index -1 is out of bounds + # ([ 1 2 3 ] == (drop (-1) [ 1 2 3 ])) + (drop 0 [ 1 2 3 ] == [ 1 2 3 ]) + (drop 1 [ 1 2 3 ] == [ 2 3 ]) + (drop 2 [ 1 2 3 ] == [ 3 ]) + (drop 3 [ 1 2 3 ] == [ ]) + (drop 4 [ 1 2 3 ] == [ ]) + (drop 0 [ ] == [ ]) + (drop 1 [ ] == [ ]) + ]; + testListHasPrefixExample1 = { expr = lists.hasPrefix [ 1 2 ] [ 1 2 3 4 ]; expected = true;