Skip to content

Commit

Permalink
lib/tests/misc: Test lib.drop
Browse files Browse the repository at this point in the history
  • Loading branch information
roberth committed Jan 3, 2025
1 parent 6eafbd0 commit c96e907
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c96e907

Please sign in to comment.