about summary refs log tree commit diff
path: root/lib/tests/misc.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-07-14 18:28:38 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-07-14 19:36:46 +0200
commit9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54 (patch)
treed0d0b4e3fb927d00bc43a29ae4fee3d41388b3bf /lib/tests/misc.nix
parentbc8fbc25723b05e0f909faa6589641867200775b (diff)
downloadnixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.tar
nixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.tar.gz
nixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.tar.bz2
nixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.tar.lz
nixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.tar.xz
nixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.tar.zst
nixlib-9fdc0bb2bfa2d1dd631bb39f3b9e7cfec16bcd54.zip
lib.lists.removePrefix: init
Diffstat (limited to 'lib/tests/misc.nix')
-rw-r--r--lib/tests/misc.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 5c824a066e16..4f7035a53f5b 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -501,6 +501,23 @@ runTests {
     expected = false;
   };
 
+  testListRemovePrefixExample1 = {
+    expr = lists.removePrefix [ 1 2 ] [ 1 2 3 4 ];
+    expected = [ 3 4 ];
+  };
+  testListRemovePrefixExample2 = {
+    expr = (builtins.tryEval (lists.removePrefix [ 0 1 ] [ 1 2 3 4 ])).success;
+    expected = false;
+  };
+  testListRemovePrefixEmptyPrefix = {
+    expr = lists.removePrefix [ ] [ 1 2 ];
+    expected = [ 1 2 ];
+  };
+  testListRemovePrefixEmptyList = {
+    expr = (builtins.tryEval (lists.removePrefix [ 1 2 ] [ ])).success;
+    expected = false;
+  };
+
   testFoldAttrs = {
     expr = foldAttrs (n: a: [n] ++ a) [] [
     { a = 2; b = 7; }