diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index a13696be..7377fba4 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1589,7 +1589,7 @@ getJasmineRequireObj().Any = function(j$) { } if (this.expectedObject == Object) { - return typeof other == 'object'; + return other !== null && typeof other == 'object'; } if (this.expectedObject == Boolean) { diff --git a/spec/core/asymmetric_equality/AnySpec.js b/spec/core/asymmetric_equality/AnySpec.js index 44ffe6b8..1739ae6f 100644 --- a/spec/core/asymmetric_equality/AnySpec.js +++ b/spec/core/asymmetric_equality/AnySpec.js @@ -68,10 +68,17 @@ describe("Any", function() { expect(any.asymmetricMatch(new Thing())).toBe(true); }); + it("does not treat null as an Object", function() { + var any = new jasmineUnderTest.Any(Object); + + expect(any.asymmetricMatch(null)).toBe(false); + }); + it("jasmineToString's itself", function() { var any = new jasmineUnderTest.Any(Number); expect(any.jasmineToString()).toEqual(''); + expect(any.jasmineToString()).toEqual(''); }); describe("when called without an argument", function() { diff --git a/src/core/asymmetric_equality/Any.js b/src/core/asymmetric_equality/Any.js index 3f447529..bc185518 100644 --- a/src/core/asymmetric_equality/Any.js +++ b/src/core/asymmetric_equality/Any.js @@ -24,7 +24,7 @@ getJasmineRequireObj().Any = function(j$) { } if (this.expectedObject == Object) { - return typeof other == 'object'; + return other !== null && typeof other == 'object'; } if (this.expectedObject == Boolean) {