diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f0c24b79..19aa8211 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1781,9 +1781,9 @@ getJasmineRequireObj().matchersUtil = function(j$) { var result = true; for (var i = 0; i < customTesters.length; i++) { - result = customTesters[i](a, b); - if (result) { - return true; + var customTesterResult = customTesters[i](a, b); + if (!j$.util.isUndefined(customTesterResult)) { + return customTesterResult; } } diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index 11b398f6..010a91c9 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -153,10 +153,22 @@ describe("matchersUtil", function() { expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(true); }); + it("passes for two empty Objects", function () { + expect(j$.matchersUtil.equals({}, {})).toBe(true); + }); + + describe("when a custom equality matcher is installed that returns 'undefined'", function () { + var tester = function(a, b) { return jasmine.undefined; }; + + it("passes for two empty Objects", function () { + expect(j$.matchersUtil.equals({}, {}, [tester])).toBe(true); + }); + }); + it("fails for equivalents when a custom equality matcher returns false", function() { var tester = function(a, b) { return false; }; - expect(j$.matchersUtil.equals(1, 2, [tester])).toBe(false); + expect(j$.matchersUtil.equals(1, 1, [tester])).toBe(false); }); }); diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js index da16d739..a40f07d1 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -52,9 +52,9 @@ getJasmineRequireObj().matchersUtil = function(j$) { var result = true; for (var i = 0; i < customTesters.length; i++) { - result = customTesters[i](a, b); - if (result) { - return true; + var customTesterResult = customTesters[i](a, b); + if (!j$.util.isUndefined(customTesterResult)) { + return customTesterResult; } } @@ -176,4 +176,4 @@ getJasmineRequireObj().matchersUtil = function(j$) { return typeof obj === 'function'; } } -}; \ No newline at end of file +};