Correct number matching in equals_
This commit is contained in:
parent
c85079e9d0
commit
bf938ffc50
|
@ -89,7 +89,7 @@ jasmine.getEnv = function() {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isArray_ = function(value) {
|
||||
return Object.prototype.toString.apply(value) === '[object Array]';
|
||||
return jasmine.isA_("Array", value);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -99,7 +99,28 @@ jasmine.isArray_ = function(value) {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isString_ = function(value) {
|
||||
return Object.prototype.toString.apply(value) === '[object String]';
|
||||
return jasmine.isA_("String", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isNumber_ = function(value) {
|
||||
return jasmine.isA_("Number", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param {String} typeName
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isA_ = function(typeName, value) {
|
||||
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -836,6 +857,10 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
|||
return (a == b);
|
||||
}
|
||||
|
||||
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
||||
return (a == b);
|
||||
}
|
||||
|
||||
if (typeof a === "object" && typeof b === "object") {
|
||||
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||
}
|
||||
|
@ -2289,5 +2314,5 @@ jasmine.version_= {
|
|||
"major": 0,
|
||||
"minor": 10,
|
||||
"build": 1,
|
||||
"revision": 1268838574
|
||||
"revision": 1268969514
|
||||
};
|
||||
|
|
|
@ -57,6 +57,11 @@ describe("jasmine.Matchers", function() {
|
|||
|
||||
expect((match(new String("cat")).toEqual("cat"))).toBe(true);
|
||||
expect((match(new String("cat")).toNotEqual("cat"))).toBe(false);
|
||||
|
||||
expect((match(new Number(5)).toEqual(5))).toBe(true);
|
||||
expect((match(new Number('5')).toEqual(5))).toBe(true);
|
||||
expect((match(new Number(5)).toNotEqual(5))).toBe(false);
|
||||
expect((match(new Number('5')).toNotEqual(5))).toBe(false);
|
||||
});
|
||||
|
||||
it("toEqual to build an Expectation Result", function() {
|
||||
|
|
|
@ -213,6 +213,10 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
|
|||
return (a == b);
|
||||
}
|
||||
|
||||
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
|
||||
return (a == b);
|
||||
}
|
||||
|
||||
if (typeof a === "object" && typeof b === "object") {
|
||||
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||
}
|
||||
|
|
25
src/base.js
25
src/base.js
|
@ -89,7 +89,7 @@ jasmine.getEnv = function() {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isArray_ = function(value) {
|
||||
return Object.prototype.toString.apply(value) === '[object Array]';
|
||||
return jasmine.isA_("Array", value);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -99,7 +99,28 @@ jasmine.isArray_ = function(value) {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isString_ = function(value) {
|
||||
return Object.prototype.toString.apply(value) === '[object String]';
|
||||
return jasmine.isA_("String", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isNumber_ = function(value) {
|
||||
return jasmine.isA_("Number", value);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
* @private
|
||||
* @param {String} typeName
|
||||
* @param value
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isA_ = function(typeName, value) {
|
||||
return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue