Remove obsolete eqStrict function
Use the "==" operator instead.
This commit is contained in:
parent
503b4fd5bf
commit
37159c1b9a
@ -6,7 +6,6 @@ with {
|
||||
inherit (import ./default.nix) fold;
|
||||
inherit (import ./strings.nix) concatStringsSep;
|
||||
inherit (import ./lists.nix) concatMap concatLists;
|
||||
inherit (import ./misc.nix) eqStrict;
|
||||
};
|
||||
|
||||
rec {
|
||||
@ -292,9 +291,9 @@ rec {
|
||||
matchAttrs = pattern: attrs:
|
||||
fold or false (attrValues (zipAttrsWithNames (attrNames pattern) (n: values:
|
||||
let pat = head values; val = head (tail values); in
|
||||
if tail values == [] then false
|
||||
if length values == 1 then false
|
||||
else if isAttrs pat then isAttrs val && matchAttrs head values
|
||||
else eqStrict pat val
|
||||
else pat == val
|
||||
) [pattern attrs]));
|
||||
|
||||
# override only the attributes that are already present in the old set
|
||||
|
@ -66,7 +66,7 @@ rec {
|
||||
let testsToRun = if tests ? tests then tests.tests else [];
|
||||
in if (substring 0 4 name == "test" || elem name testsToRun)
|
||||
&& ((testsToRun == []) || elem name tests.tests)
|
||||
&& (!lib.eqStrict test.expr test.expected)
|
||||
&& (test.expr != test.expected)
|
||||
|
||||
then [ { inherit name; expected = test.expected; result = test.expr; } ]
|
||||
else [] ) tests));
|
||||
|
@ -390,18 +390,4 @@ rec {
|
||||
else if isInt x then "int"
|
||||
else "string";
|
||||
|
||||
# deep, strict equality testing. This should be implemented as primop
|
||||
eqStrict = a : b :
|
||||
let eqListStrict = a : b :
|
||||
if (a == []) != (b == []) then false
|
||||
else if a == [] then true
|
||||
else eqStrict (head a) (head b) && eqListStrict (tail a) (tail b);
|
||||
in
|
||||
if nixType a != nixType b then false
|
||||
else if isList a then eqListStrict a b
|
||||
else if isAttrs a then
|
||||
(eqListStrict (attrNames a) (attrNames b))
|
||||
&& (eqListStrict (lib.attrValues a) (lib.attrValues b))
|
||||
else a == b; # FIXME !
|
||||
|
||||
}
|
||||
|
@ -50,19 +50,6 @@ runTests {
|
||||
expected = 5050;
|
||||
};
|
||||
|
||||
testEqStrict = {
|
||||
expr = all id [
|
||||
(eqStrict 2 2)
|
||||
(!eqStrict 3 2)
|
||||
(eqStrict [2 1] [2 1])
|
||||
(!eqStrict [1 3] [1 2])
|
||||
(eqStrict {a = 7; b = 20;} {b= 20; a = 7;})
|
||||
(eqStrict [{a = 7; b = 20;}] [{b= 20; a = 7;}])
|
||||
(eqStrict {a = [7 8]; b = 20;} {b= 20; a = [7 8];})
|
||||
];
|
||||
expected = true;
|
||||
};
|
||||
|
||||
testTake = testAllTrue [
|
||||
([] == (take 0 [ 1 2 3 ]))
|
||||
([1] == (take 1 [ 1 2 3 ]))
|
||||
@ -99,14 +86,14 @@ runTests {
|
||||
in (y.merge) { b = 10; };
|
||||
strip = attrs : removeAttrs attrs ["merge" "replace"];
|
||||
in all id
|
||||
[ (eqStrict (strip res1) { })
|
||||
(eqStrict (strip res2) { a = 7; })
|
||||
(eqStrict (strip res3) { a = 7; b = 10; })
|
||||
(eqStrict (strip res4) { a = 7; b = 10; })
|
||||
(eqStrict (strip res5) { a = 10; })
|
||||
(eqStrict (strip res6) { a = 17; })
|
||||
(eqStrict (strip resRem7) {})
|
||||
(eqStrict (strip resFixed1) { a = 7; b = 10; c =10; name = "name-10"; })
|
||||
[ ((strip res1) == { })
|
||||
((strip res2) == { a = 7; })
|
||||
((strip res3) == { a = 7; b = 10; })
|
||||
((strip res4) == { a = 7; b = 10; })
|
||||
((strip res5) == { a = 10; })
|
||||
((strip res6) == { a = 17; })
|
||||
((strip resRem7) == {})
|
||||
((strip resFixed1) == { a = 7; b = 10; c =10; name = "name-10"; })
|
||||
];
|
||||
expected = true;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user