Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
3.2 kB · 178 lines
Nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179# NOTE: Tests related to sortArray go here.{ lib, sortArray, testers,}:let inherit (lib.attrsets) recurseIntoAttrs; inherit (testers) shellcheck shfmt testEqualArrayOrMap; check = { name, valuesArray, expectedArray, }: (testEqualArrayOrMap { inherit name valuesArray expectedArray; script = '' set -eu nixLog "running sortArray with valuesArray to populate actualArray" sortArray valuesArray actualArray ''; }).overrideAttrs (prevAttrs: { nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ sortArray ]; });
checkInPlace = { name, valuesArray, expectedArray, }: (testEqualArrayOrMap { inherit name valuesArray expectedArray; script = '' set -eu nixLog "running sortArray with valuesArray as input and output" sortArray valuesArray valuesArray nixLog "copying valuesArray to actualArray" actualArray=("''${valuesArray[@]}") ''; }).overrideAttrs (prevAttrs: { nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ sortArray ]; });inrecurseIntoAttrs { shellcheck = shellcheck { name = "sortArray"; src = ./sortArray.bash; };
shfmt = shfmt { name = "sortArray"; src = ./sortArray.bash; };
empty = check { name = "empty"; valuesArray = [ ]; expectedArray = [ ]; };
singleton = check { name = "singleton"; valuesArray = [ "apple" ]; expectedArray = [ "apple" ]; };
oneDuplicate = check { name = "oneDuplicate"; valuesArray = [ "apple" "apple" ]; expectedArray = [ "apple" "apple" ]; };
oneUnique = check { name = "oneUnique"; valuesArray = [ "bee" "apple" "bee" ]; expectedArray = [ "apple" "bee" "bee" ]; };
duplicatesWithSpacesAndLineBreaks = check { name = "duplicatesWithSpacesAndLineBreaks"; valuesArray = [ "dog" "bee" '' line break '' "cat" "zebra" "bee" "cat" "elephant" "dog with spaces" '' line break '' ]; expectedArray = [ "bee" "bee" "cat" "cat" "dog" "dog with spaces" "elephant" # NOTE: lead whitespace is removed, so the following entries start with `l`. '' line break '' '' line break '' "zebra" ]; };
duplicatesWithSpacesAndLineBreaksInPlace = checkInPlace { name = "duplicatesWithSpacesAndLineBreaksInPlace"; valuesArray = [ "dog" "bee" '' line break '' "cat" "zebra" "bee" "cat" "elephant" "dog with spaces" '' line break '' ]; expectedArray = [ "bee" "bee" "cat" "cat" "dog" "dog with spaces" "elephant" # NOTE: lead whitespace is removed, so the following entries start with `l`. '' line break '' '' line break '' "zebra" ]; };}