diff options
author | Naïm Favier <n@monade.li> | 2022-12-20 18:38:47 +0100 |
---|---|---|
committer | Naïm Favier <n@monade.li> | 2022-12-21 12:58:21 +0100 |
commit | 03554797153aa90263161784c296ef6518af3358 (patch) | |
tree | f7ddfee6960e6d04a4696ea9c58195412c0e5b85 /lib/tests/misc.nix | |
parent | 3ff39f984faa5f528f7ac5e548110d4e20327aa1 (diff) | |
download | nixpkgs-03554797153aa90263161784c296ef6518af3358.tar nixpkgs-03554797153aa90263161784c296ef6518af3358.tar.gz nixpkgs-03554797153aa90263161784c296ef6518af3358.tar.bz2 nixpkgs-03554797153aa90263161784c296ef6518af3358.tar.lz nixpkgs-03554797153aa90263161784c296ef6518af3358.tar.xz nixpkgs-03554797153aa90263161784c296ef6518af3358.tar.zst nixpkgs-03554797153aa90263161784c296ef6518af3358.zip |
lib/versions: add `pad`
Pad a version string with zeros to match a given number of components.
Diffstat (limited to 'lib/tests/misc.nix')
-rw-r--r-- | lib/tests/misc.nix | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index c719fcf5d4f..faf2b96530c 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -212,6 +212,21 @@ runTests { expected = [ "1" "2" "3" ]; }; + testPadVersionLess = { + expr = versions.pad 3 "1.2"; + expected = "1.2.0"; + }; + + testPadVersionLessExtra = { + expr = versions.pad 3 "1.3-rc1"; + expected = "1.3.0-rc1"; + }; + + testPadVersionMore = { + expr = versions.pad 3 "1.2.3.4"; + expected = "1.2.3"; + }; + testIsStorePath = { expr = let goodPath = |