summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-13 18:08:35 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-13 18:08:35 -0400
commit37159c1b9a0ec77306866c539fbcd7b0e230f2d9 (patch)
tree4bc7b3ce91ffdca4db75967fecb574848d12261f
parent503b4fd5bfd2a516ebd61870d2e09970b56ff41a (diff)
downloadnixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.tar
nixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.tar.gz
nixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.tar.bz2
nixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.tar.lz
nixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.tar.xz
nixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.tar.zst
nixpkgs-37159c1b9a0ec77306866c539fbcd7b0e230f2d9.zip
Remove obsolete eqStrict function
Use the "==" operator instead.
-rw-r--r--pkgs/lib/attrsets.nix5
-rw-r--r--pkgs/lib/debug.nix2
-rw-r--r--pkgs/lib/misc.nix14
-rw-r--r--pkgs/lib/tests.nix29
4 files changed, 11 insertions, 39 deletions
diff --git a/pkgs/lib/attrsets.nix b/pkgs/lib/attrsets.nix
index 982f23230c9..de6eccbec1f 100644
--- a/pkgs/lib/attrsets.nix
+++ b/pkgs/lib/attrsets.nix
@@ -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
diff --git a/pkgs/lib/debug.nix b/pkgs/lib/debug.nix
index e452151add6..b78f946c5d4 100644
--- a/pkgs/lib/debug.nix
+++ b/pkgs/lib/debug.nix
@@ -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));
diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix
index dbf3381f0f4..f4a629398b5 100644
--- a/pkgs/lib/misc.nix
+++ b/pkgs/lib/misc.nix
@@ -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 !
-
 }
diff --git a/pkgs/lib/tests.nix b/pkgs/lib/tests.nix
index 646de7c0e49..835298ddb9e 100644
--- a/pkgs/lib/tests.nix
+++ b/pkgs/lib/tests.nix
@@ -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;
   };