Skip to content
Browse files

should be compatible w/ Safari now

  • Loading branch information...
1 parent 9740d89 commit 07b7a5962ea53be72c69fae855512fea69241f34 Nick Kallen committed May 3, 2008
Showing with 18 additions and 17 deletions.
  1. +18 −17 lib/screw.matchers.js
View
35 lib/screw.matchers.js
@@ -14,27 +14,13 @@ Screw.Matchers = {
},
equal: {
match: function(expected, actual) {
- if (Screw.Matchers.equal.by_type[expected.constructor.name])
- return Screw.Matchers.equal.by_type[expected.constructor.name](expected, actual);
+ if (Screw.Matchers.equal.by_type[expected.constructor])
+ return Screw.Matchers.equal.by_type[expected.constructor](expected, actual);
else
return expected == actual;
},
failure_message: function(expected, actual, not) {
return 'expected ' + $([actual]).print() + (not ? ' to not equal ' : ' to equal ') + $([expected]).print();
- },
- by_type: {
- Array: function(expected, actual) {
- for (var i = 0; i < actual.length; i++)
- if (!Screw.Matchers.equal.match(expected[i], actual[i])) return false;
- return actual.length == expected.length;
- },
- Object: function(expected, actual) {
- for (var key in expected)
- if (!Screw.Matchers.equal.match(expected[key], actual[key])) return false;
- for (var key in actual)
- if (!Screw.Matchers.equal.match(actual[key], expected[key])) return false;
- return true;
- }
}
},
match: {
@@ -60,4 +46,19 @@ Screw.Matchers = {
return 'expected ' + $([actual]).print() + (not ? ' to not be empty' : ' to be empty');
}
}
-}
+};
+
+Screw.Matchers.equal.by_type = {};
+Screw.Matchers.equal.by_type[Array] = function(expected, actual) {
+ for (var i = 0; i < actual.length; i++)
+ if (!Screw.Matchers.equal.match(expected[i], actual[i])) return false;
+ return actual.length == expected.length;
+};
+
+Screw.Matchers.equal.by_type[Object] = function(expected, actual) {
+ for (var key in expected)
+ if (!Screw.Matchers.equal.match(expected[key], actual[key])) return false;
+ for (var key in actual)
+ if (!Screw.Matchers.equal.match(actual[key], expected[key])) return false;
+ return true;
+};

0 comments on commit 07b7a59

Please sign in to comment.
Something went wrong with that request. Please try again.