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}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
jasmine.isArray_ = function(value) {
|
jasmine.isArray_ = function(value) {
|
||||||
return value &&
|
return Object.prototype.toString.apply(value) === '[object Array]';
|
||||||
typeof value === 'object' &&
|
|
||||||
typeof value.length === 'number' &&
|
|
||||||
typeof value.splice === 'function' &&
|
|
||||||
!(value.propertyIsEnumerable('length'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2261,5 +2257,5 @@ jasmine.version_= {
|
|||||||
"major": 0,
|
"major": 0,
|
||||||
"minor": 10,
|
"minor": 10,
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"revision": 1267068340
|
"revision": 1267068885
|
||||||
};
|
};
|
||||||
|
@ -20,4 +20,21 @@ describe("jasmine.util", function() {
|
|||||||
expect(destination).toEqual({foo: null});
|
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}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
jasmine.isArray_ = function(value) {
|
jasmine.isArray_ = function(value) {
|
||||||
return value &&
|
return Object.prototype.toString.apply(value) === '[object Array]';
|
||||||
typeof value === 'object' &&
|
|
||||||
typeof value.length === 'number' &&
|
|
||||||
typeof value.splice === 'function' &&
|
|
||||||
!(value.propertyIsEnumerable('length'));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user