From bc8fbc25723b05e0f909faa6589641867200775b Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 14 Jul 2023 18:18:48 +0200 Subject: lib.lists.hasPrefix: init --- lib/tests/misc.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/tests/misc.nix') diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index ce980436c1bcb..5c824a066e16f 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -480,6 +480,27 @@ runTests { ([ 1 2 3 ] == (take 4 [ 1 2 3 ])) ]; + testListHasPrefixExample1 = { + expr = lists.hasPrefix [ 1 2 ] [ 1 2 3 4 ]; + expected = true; + }; + testListHasPrefixExample2 = { + expr = lists.hasPrefix [ 0 1 ] [ 1 2 3 4 ]; + expected = false; + }; + testListHasPrefixLazy = { + expr = lists.hasPrefix [ 1 ] [ 1 (abort "lib.lists.hasPrefix is not lazy") ]; + expected = true; + }; + testListHasPrefixEmptyPrefix = { + expr = lists.hasPrefix [ ] [ 1 2 ]; + expected = true; + }; + testListHasPrefixEmptyList = { + expr = lists.hasPrefix [ 1 2 ] [ ]; + expected = false; + }; + testFoldAttrs = { expr = foldAttrs (n: a: [n] ++ a) [] [ { a = 2; b = 7; } -- cgit 1.4.1