mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Increase test coverage.
This commit is contained in:
@@ -38,15 +38,15 @@
|
|||||||
function addBizarroMethods() {
|
function addBizarroMethods() {
|
||||||
// allow bypassing native checks
|
// allow bypassing native checks
|
||||||
setProperty(Function.prototype, 'toString', (function() {
|
setProperty(Function.prototype, 'toString', (function() {
|
||||||
function fnToString() {
|
function wrapper() {
|
||||||
setProperty(Function.prototype, 'toString', _fnToString);
|
|
||||||
var result = this === Set ? this.toString() : _fnToString.call(this);
|
|
||||||
setProperty(Function.prototype, 'toString', fnToString);
|
setProperty(Function.prototype, 'toString', fnToString);
|
||||||
|
var result = this === Set ? this.toString() : fnToString.call(this);
|
||||||
|
setProperty(Function.prototype, 'toString', wrapper);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
var _fnToString = Function.prototype.toString;
|
var fnToString = Function.prototype.toString;
|
||||||
setProperty(Function.prototype, '_toString', _fnToString);
|
setProperty(Function.prototype, '_toString', fnToString);
|
||||||
return fnToString;
|
return wrapper;
|
||||||
}()));
|
}()));
|
||||||
|
|
||||||
// add extensions
|
// add extensions
|
||||||
@@ -71,6 +71,23 @@
|
|||||||
setProperty(Object, '_keys', Object.keys);
|
setProperty(Object, '_keys', Object.keys);
|
||||||
setProperty(Object, 'keys', function() {});
|
setProperty(Object, 'keys', function() {});
|
||||||
|
|
||||||
|
setProperty(Object.prototype, 'hasOwnProperty', (function() {
|
||||||
|
function wrapper(key) {
|
||||||
|
if (key == '1' && this && typeof this == 'object' && this.length === 2 &&
|
||||||
|
hasOwnProperty.call(this, 'callee') &&
|
||||||
|
!propertyIsEnumerable.call(this, 'callee') &&
|
||||||
|
this[0] === 0 && this[1] === 0) {
|
||||||
|
throw new Error;
|
||||||
|
}
|
||||||
|
return hasOwnProperty.call(this, key);
|
||||||
|
}
|
||||||
|
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||||
|
propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||||||
|
|
||||||
|
setProperty(Object.prototype, '_hasOwnProperty', hasOwnProperty);
|
||||||
|
return wrapper;
|
||||||
|
}()));
|
||||||
|
|
||||||
setProperty(String.prototype, '_contains', String.prototype.contains);
|
setProperty(String.prototype, '_contains', String.prototype.contains);
|
||||||
setProperty(String.prototype, 'contains', String.prototype._contains ? function() {} : Boolean);
|
setProperty(String.prototype, 'contains', String.prototype._contains ? function() {} : Boolean);
|
||||||
|
|
||||||
@@ -118,6 +135,7 @@
|
|||||||
}
|
}
|
||||||
setProperty(window, 'WinRTError', undefined);
|
setProperty(window, 'WinRTError', undefined);
|
||||||
setProperty(Function.prototype, 'toString', Function.prototype._toString);
|
setProperty(Function.prototype, 'toString', Function.prototype._toString);
|
||||||
|
setProperty(Object.prototype, 'hasOwnProperty', Object.prototype._hasOwnProperty);
|
||||||
|
|
||||||
document.createDocumentFragment = document._createDocumentFragment;
|
document.createDocumentFragment = document._createDocumentFragment;
|
||||||
setProperty(document, '_createDocumentFragment', undefined);
|
setProperty(document, '_createDocumentFragment', undefined);
|
||||||
@@ -130,6 +148,7 @@
|
|||||||
delete Object._defineProperty;
|
delete Object._defineProperty;
|
||||||
delete Object._getPrototypeOf;
|
delete Object._getPrototypeOf;
|
||||||
delete Object._keys;
|
delete Object._keys;
|
||||||
|
delete Object.prototype._hasOwnProperty;
|
||||||
delete String.prototype._contains;
|
delete String.prototype._contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
test/test.js
24
test/test.js
@@ -297,15 +297,12 @@
|
|||||||
}
|
}
|
||||||
// allow bypassing native checks
|
// allow bypassing native checks
|
||||||
var _fnToString = Function.prototype.toString;
|
var _fnToString = Function.prototype.toString;
|
||||||
setProperty(Function.prototype, 'toString', (function() {
|
setProperty(Function.prototype, 'toString', function wrapper() {
|
||||||
function fnToString() {
|
setProperty(Function.prototype, 'toString', _fnToString);
|
||||||
setProperty(Function.prototype, 'toString', _fnToString);
|
var result = this === Set ? this.toString() : _fnToString.call(this);
|
||||||
var result = this === Set ? this.toString() : _fnToString.call(this);
|
setProperty(Function.prototype, 'toString', wrapper);
|
||||||
setProperty(Function.prototype, 'toString', fnToString);
|
return result;
|
||||||
return result;
|
});
|
||||||
}
|
|
||||||
return fnToString;
|
|
||||||
}()));
|
|
||||||
|
|
||||||
// fake DOM
|
// fake DOM
|
||||||
setProperty(global, 'window', {});
|
setProperty(global, 'window', {});
|
||||||
@@ -339,6 +336,14 @@
|
|||||||
var _keys = Object.keys;
|
var _keys = Object.keys;
|
||||||
setProperty(Object, 'keys', function() {});
|
setProperty(Object, 'keys', function() {});
|
||||||
|
|
||||||
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
setProperty(Object.prototype, 'hasOwnProperty', function(key) {
|
||||||
|
if (key == '1' && _.isArguments(this) && _.isEqual(_.values(this), [0, 0])) {
|
||||||
|
throw new Error;
|
||||||
|
}
|
||||||
|
return _hasOwnProperty.call(this, key);
|
||||||
|
});
|
||||||
|
|
||||||
var _contains = String.prototype.contains;
|
var _contains = String.prototype.contains;
|
||||||
setProperty(String.prototype, 'contains', _contains ? function() {} : Boolean);
|
setProperty(String.prototype, 'contains', _contains ? function() {} : Boolean);
|
||||||
|
|
||||||
@@ -355,6 +360,7 @@
|
|||||||
setProperty(Object, 'defineProperty', _defineProperty);
|
setProperty(Object, 'defineProperty', _defineProperty);
|
||||||
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
|
setProperty(Object, 'getPrototypeOf', _getPrototypeOf);
|
||||||
setProperty(Object, 'keys', _keys);
|
setProperty(Object, 'keys', _keys);
|
||||||
|
setProperty(Object.prototype, 'hasOwnProperty', _hasOwnProperty);
|
||||||
setProperty(Function.prototype, 'toString', _fnToString);
|
setProperty(Function.prototype, 'toString', _fnToString);
|
||||||
|
|
||||||
if (_contains) {
|
if (_contains) {
|
||||||
|
|||||||
Reference in New Issue
Block a user