Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Remove _.support use.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jul 19, 2015
1 parent bc266eb commit 8c2b72a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 40 deletions.
46 changes: 18 additions & 28 deletions benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,6 @@
*/
support.timeout = isHostType(context, 'setTimeout') && isHostType(context, 'clearTimeout');

/**
* Detect if `Array#unshift` returns the new length of the array (all but IE < 8).
*
* @memberOf Benchmark.support
* @type boolean
*/
support.unshiftResult = !![].unshift(1);

/**
* Detect if function decompilation is support.
*
Expand Down Expand Up @@ -2813,30 +2805,28 @@

// Avoid array-like object bugs with `Array#shift` and `Array#splice`
// in Firefox < 10 and IE < 9.
if (!_.support.spliceObjects) {
_.each(['pop', 'shift', 'splice'], function(methodName) {
var func = arrayRef[methodName];
_.each(['pop', 'shift', 'splice'], function(methodName) {
var func = arrayRef[methodName];

Suite.prototype[methodName] = function() {
var value = this,
result = func.apply(value, arguments);
Suite.prototype[methodName] = function() {
var value = this,
result = func.apply(value, arguments);

if (value.length === 0) {
delete value[0];
}
return result;
};
});

if (value.length === 0) {
delete value[0];
}
return result;
};
});
}
// Avoid buggy `Array#unshift` in IE < 8 which doesn't return the new
// length of the array.
if (!support.unshiftResult) {
Suite.prototype.unshift = function() {
var value = this;
unshift.apply(value, arguments);
return value.length;
};
}
Suite.prototype.unshift = function() {
var value = this;
unshift.apply(value, arguments);
return value.length;
};

return Benchmark;
}

Expand Down
24 changes: 12 additions & 12 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@
deepEqual(slice.call(suite), []);
});

test('should have no elements when length is 0 after shift', function() {
test('should have no elements when length is `0` after shift', function() {
var suite = Benchmark.Suite();
suite[0] = 0;
suite.length = 1;
Expand All @@ -981,17 +981,6 @@
QUnit.module('Benchmark.Suite#splice');

(function() {
test('should have no elements when length is 0 after splice', function() {
var suite = Benchmark.Suite();
suite[0] = 0;
suite.length = 1
suite.splice(0, 1);

// ensure element is removed
equal('0' in suite, false);
equal(suite.length, 0);
});

test('works with positive `start` argument', function() {
var suite = Benchmark.Suite();
suite[0] = 0;
Expand Down Expand Up @@ -1046,6 +1035,17 @@
deepEqual(actual, []);
deepEqual(slice.call(suite), [1, 2, 0, 3]);
});

test('should have no elements when length is `0` after splice', function() {
var suite = Benchmark.Suite();
suite[0] = 0;
suite.length = 1
suite.splice(0, 1);

// ensure element is removed
equal('0' in suite, false);
equal(suite.length, 0);
});
}());

/*--------------------------------------------------------------------------*/
Expand Down

0 comments on commit 8c2b72a

Please sign in to comment.