Update isArray_ function and add test coverage
This commit is contained in:
parent
5e3eb884ca
commit
6ca766d5ea
|
@ -89,11 +89,7 @@ jasmine.getEnv = function() {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isArray_ = function(value) {
|
||||
return value &&
|
||||
typeof value === 'object' &&
|
||||
typeof value.length === 'number' &&
|
||||
typeof value.splice === 'function' &&
|
||||
!(value.propertyIsEnumerable('length'));
|
||||
return Object.prototype.toString.apply(value) === '[object Array]';
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2261,5 +2257,5 @@ jasmine.version_= {
|
|||
"major": 0,
|
||||
"minor": 10,
|
||||
"build": 0,
|
||||
"revision": 1267068340
|
||||
"revision": 1267068885
|
||||
};
|
||||
|
|
|
@ -20,4 +20,21 @@ describe("jasmine.util", function() {
|
|||
expect(destination).toEqual({foo: null});
|
||||
});
|
||||
});
|
||||
|
||||
describe("isArray_", function() {
|
||||
it("should return true if the argument is an array", function() {
|
||||
expect(jasmine.isArray_([])).toBe(true);
|
||||
expect(jasmine.isArray_(['a'])).toBe(true);
|
||||
expect(jasmine.isArray_(new Array())).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false if the argument is not an array", function() {
|
||||
expect(jasmine.isArray_(undefined)).toBe(false);
|
||||
expect(jasmine.isArray_({})).toBe(false);
|
||||
expect(jasmine.isArray_(function() {})).toBe(false);
|
||||
expect(jasmine.isArray_('foo')).toBe(false);
|
||||
expect(jasmine.isArray_(5)).toBe(false);
|
||||
expect(jasmine.isArray_(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -89,11 +89,7 @@ jasmine.getEnv = function() {
|
|||
* @returns {Boolean}
|
||||
*/
|
||||
jasmine.isArray_ = function(value) {
|
||||
return value &&
|
||||
typeof value === 'object' &&
|
||||
typeof value.length === 'number' &&
|
||||
typeof value.splice === 'function' &&
|
||||
!(value.propertyIsEnumerable('length'));
|
||||
return Object.prototype.toString.apply(value) === '[object Array]';
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue