···1# to run these tests:
2# nix-instantiate --eval --strict nixpkgs/lib/tests/misc.nix
3# if the resulting list is empty, all tests passed
4-let inherit (builtins) add; in
5with import ../default.nix;
67runTests {
···86 testSplitStringsLastEmpty = {
87 expr = strings.splitString ":" "2001:db8:0:0042::8a2e:370:";
88 expected = [ "2001" "db8" "0" "0042" "" "8a2e" "370" "" ];
000000000000000000000000000000089 };
9091# LISTS
···266 res4 = let x = defaultOverridableDelayableArgs id { a = 7; };
267 in (x.merge) ( x: { b = 10; });
268 res5 = let x = defaultOverridableDelayableArgs id { a = 7; };
269- in (x.merge) ( x: { a = add x.a 3; });
270- res6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = add; }; };
271 y = x.merge {};
272 in (y.merge) { a = 10; };
273274 resRem7 = res6.replace (a: removeAttrs a ["a"]);
275276- resReplace6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = add; }; };
277 x2 = x.merge { a = 20; }; # now we have 27
278 in (x2.replace) { a = 10; }; # and override the value by 10
279
···1# to run these tests:
2# nix-instantiate --eval --strict nixpkgs/lib/tests/misc.nix
3# if the resulting list is empty, all tests passed
04with import ../default.nix;
56runTests {
···85 testSplitStringsLastEmpty = {
86 expr = strings.splitString ":" "2001:db8:0:0042::8a2e:370:";
87 expected = [ "2001" "db8" "0" "0042" "" "8a2e" "370" "" ];
88+ };
89+90+ testIsStorePath = {
91+ expr =
92+ let goodPath =
93+ "/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11";
94+ in {
95+ storePath = isStorePath goodPath;
96+ storePathAppendix = isStorePath
97+ "${goodPath}/bin/python";
98+ nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
99+ asPath = isStorePath (builtins.toPath goodPath);
100+ otherPath = isStorePath "/something/else";
101+ otherVals = {
102+ attrset = isStorePath {};
103+ list = isStorePath [];
104+ int = isStorePath 42;
105+ };
106+ };
107+ expected = {
108+ storePath = true;
109+ storePathAppendix = false;
110+ nonAbsolute = false;
111+ asPath = true;
112+ otherPath = false;
113+ otherVals = {
114+ attrset = false;
115+ list = false;
116+ int = false;
117+ };
118+ };
119 };
120121# LISTS
···296 res4 = let x = defaultOverridableDelayableArgs id { a = 7; };
297 in (x.merge) ( x: { b = 10; });
298 res5 = let x = defaultOverridableDelayableArgs id { a = 7; };
299+ in (x.merge) ( x: { a = builtins.add x.a 3; });
300+ res6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = builtins.add; }; };
301 y = x.merge {};
302 in (y.merge) { a = 10; };
303304 resRem7 = res6.replace (a: removeAttrs a ["a"]);
305306+ resReplace6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = builtins.add; }; };
307 x2 = x.merge { a = 20; }; # now we have 27
308 in (x2.replace) { a = 10; }; # and override the value by 10
309