Remove rhino testing.

This commit is contained in:
John-David Dalton
2015-11-29 12:00:53 -06:00
parent e778458f78
commit fdc15df3b3
3 changed files with 314 additions and 524 deletions

View File

@@ -10,8 +10,6 @@ Dont worry about regenerating the documentation, lodash.js, or lodash.min.js.
Before running the unit tests youll need to install, `npm i`, [development dependencies](https://docs.npmjs.com/files/package.json#devdependencies). Before running the unit tests youll need to install, `npm i`, [development dependencies](https://docs.npmjs.com/files/package.json#devdependencies).
Run unit tests from the command-line via `node test/test`, or open `test/index.html` in a web browser. Run unit tests from the command-line via `node test/test`, or open `test/index.html` in a web browser.
The `test/run-test.sh` script attempts to run the tests in [Rhino](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino), [RingoJS](http://ringojs.org/), [PhantomJS](http://phantomjs.org/), & [Node](http://nodejs.org/), before running them in your default browser.
The [Backbone](http://backbonejs.org/) & [Underscore](http://underscorejs.org/) test suites are included as well. The [Backbone](http://backbonejs.org/) & [Underscore](http://underscorejs.org/) test suites are included as well.
## Contributor License Agreement ## Contributor License Agreement

View File

@@ -1,14 +0,0 @@
cd "$(dirname "$0")"
echo "Testing in node..."
node test.js ../lodash.js
for cmd in rhino "rhino -require" ringo phantomjs; do
echo ""
echo "Testing in $cmd..."
$cmd test.js ../lodash.js
done
echo ""
echo "Testing in a browser..."
open index.html

View File

@@ -123,9 +123,6 @@
/** The basename of the lodash file to test. */ /** The basename of the lodash file to test. */
var basename = /[\w.-]+$/.exec(filePath)[0]; var basename = /[\w.-]+$/.exec(filePath)[0];
/** Detect if in a Java environment. */
var isJava = !document && !!root.java;
/** Used to indicate testing a modularized build. */ /** Used to indicate testing a modularized build. */
var isModularize = ui.isModularize; var isModularize = ui.isModularize;
@@ -135,9 +132,6 @@
/** Detect if running in PhantomJS. */ /** Detect if running in PhantomJS. */
var isPhantom = phantom || typeof callPhantom == 'function'; var isPhantom = phantom || typeof callPhantom == 'function';
/** Detect if running in Rhino. */
var isRhino = isJava && typeof global == 'function' && global().Array === root.Array;
/** Detect if lodash is in strict mode. */ /** Detect if lodash is in strict mode. */
var isStrict = ui.isStrict; var isStrict = ui.isStrict;
@@ -207,18 +201,15 @@
/** Use a single "load" function. */ /** Use a single "load" function. */
var load = (!amd && typeof require == 'function') var load = (!amd && typeof require == 'function')
? require ? require
: (isJava ? root.load : noop); : noop;
/** The unit testing framework. */ /** The unit testing framework. */
var QUnit = root.QUnit || (root.QUnit = ( var QUnit = root.QUnit || (root.QUnit = load('../node_modules/qunitjs/qunit/qunit.js'));
QUnit = load('../node_modules/qunitjs/qunit/qunit.js') || root.QUnit,
QUnit = QUnit.QUnit || QUnit
));
/** Load stable Lodash and QUnit Extras. */ /** Load stable Lodash and QUnit Extras. */
var lodashStable = root.lodashStable || load('../node_modules/lodash/index.js'); var lodashStable = root.lodashStable || load('../node_modules/lodash/index.js');
if (lodashStable) { if (lodashStable) {
lodashStable.runInContext(root); lodashStable = lodashStable.runInContext(root);
} }
var QUnitExtras = load('../node_modules/qunit-extras/qunit-extras.js'); var QUnitExtras = load('../node_modules/qunit-extras/qunit-extras.js');
if (QUnitExtras) { if (QUnitExtras) {
@@ -227,7 +218,7 @@
/** The `lodash` function to test. */ /** The `lodash` function to test. */
var _ = root._ || (root._ = ( var _ = root._ || (root._ = (
_ = load(filePath) || root._, _ = load(filePath),
_ = _._ || (isStrict = ui.isStrict = isStrict || 'default' in _, _['default']) || _, _ = _._ || (isStrict = ui.isStrict = isStrict || 'default' in _, _['default']) || _,
(_.runInContext ? _.runInContext(root) : _) (_.runInContext ? _.runInContext(root) : _)
)); ));
@@ -3326,7 +3317,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
debounced = _.debounce(function() { callCount++; }, 32); debounced = _.debounce(function() { callCount++; }, 32);
@@ -3340,11 +3330,6 @@
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
done(); done();
}, 96); }, 96);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('subsequent debounced calls return the last `func` result', function(assert) { QUnit.test('subsequent debounced calls return the last `func` result', function(assert) {
@@ -3352,7 +3337,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var debounced = _.debounce(identity, 32); var debounced = _.debounce(identity, 32);
debounced('x'); debounced('x');
@@ -3364,11 +3348,6 @@
assert.notEqual(debounced('z'), 'z'); assert.notEqual(debounced('z'), 'z');
done(); done();
}, 128); }, 128);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('subsequent "immediate" debounced calls return the last `func` result', function(assert) { QUnit.test('subsequent "immediate" debounced calls return the last `func` result', function(assert) {
@@ -3376,7 +3355,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var debounced = _.debounce(identity, 32, { 'leading': true, 'trailing': false }), var debounced = _.debounce(identity, 32, { 'leading': true, 'trailing': false }),
result = [debounced('x'), debounced('y')]; result = [debounced('x'), debounced('y')];
@@ -3387,11 +3365,6 @@
assert.deepEqual(result, ['a', 'a']); assert.deepEqual(result, ['a', 'a']);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('should apply default options', function(assert) { QUnit.test('should apply default options', function(assert) {
@@ -3399,7 +3372,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var debounced = _.debounce(function(value) { var debounced = _.debounce(function(value) {
@@ -3413,11 +3385,6 @@
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('should support a `leading` option', function(assert) { QUnit.test('should support a `leading` option', function(assert) {
@@ -3425,7 +3392,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCounts = [0, 0]; var callCounts = [0, 0];
var withLeading = _.debounce(function(value) { var withLeading = _.debounce(function(value) {
@@ -3455,11 +3421,6 @@
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 5);
done();
}
}); });
QUnit.test('should support a `trailing` option', function(assert) { QUnit.test('should support a `trailing` option', function(assert) {
@@ -3467,7 +3428,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var withCount = 0, var withCount = 0,
withoutCount = 0; withoutCount = 0;
@@ -3489,11 +3449,6 @@
assert.strictEqual(withoutCount, 0); assert.strictEqual(withoutCount, 0);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 4);
done();
}
}); });
QUnit.test('should support a `maxWait` option', function(assert) { QUnit.test('should support a `maxWait` option', function(assert) {
@@ -3501,7 +3456,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var limit = (argv || isPhantom) ? 1000 : 320, var limit = (argv || isPhantom) ? 1000 : 320,
withCount = 0, withCount = 0,
withoutCount = 0; withoutCount = 0;
@@ -3525,11 +3479,6 @@
assert.deepEqual(actual, [true, false]); assert.deepEqual(actual, [true, false]);
done(); done();
}, 1); }, 1);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('should cancel `maxDelayed` when `delayed` is invoked', function(assert) { QUnit.test('should cancel `maxDelayed` when `delayed` is invoked', function(assert) {
@@ -3537,7 +3486,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var debounced = _.debounce(function() { var debounced = _.debounce(function() {
@@ -3550,11 +3498,6 @@
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
done(); done();
}, 128); }, 128);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('should invoke the `trailing` call with the correct arguments and `this` binding', function(assert) { QUnit.test('should invoke the `trailing` call with the correct arguments and `this` binding', function(assert) {
@@ -3562,7 +3505,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var actual, var actual,
callCount = 0, callCount = 0,
object = {}; object = {};
@@ -3583,11 +3525,6 @@
assert.deepEqual(actual, [object, 'a']); assert.deepEqual(actual, [object, 'a']);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
}()); }());
@@ -3765,7 +3702,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var pass = false; var pass = false;
_.defer(function() { pass = true; }); _.defer(function() { pass = true; });
@@ -3773,11 +3709,6 @@
assert.ok(pass); assert.ok(pass);
done(); done();
}, 32); }, 32);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('should provide additional arguments to `func`', function(assert) { QUnit.test('should provide additional arguments to `func`', function(assert) {
@@ -3785,7 +3716,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var args; var args;
_.defer(function() { _.defer(function() {
@@ -3796,11 +3726,6 @@
assert.deepEqual(args, [1, 2]); assert.deepEqual(args, [1, 2]);
done(); done();
}, 32); }, 32);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('should be cancelable', function(assert) { QUnit.test('should be cancelable', function(assert) {
@@ -3808,7 +3733,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var pass = true; var pass = true;
var timerId = _.defer(function() { var timerId = _.defer(function() {
@@ -3821,11 +3745,6 @@
assert.ok(pass); assert.ok(pass);
done(); done();
}, 32); }, 32);
}
else {
skipTest(assert);
done();
}
}); });
}()); }());
@@ -3839,7 +3758,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var pass = false; var pass = false;
_.delay(function() { pass = true; }, 32); _.delay(function() { pass = true; }, 32);
@@ -3851,11 +3769,6 @@
assert.ok(pass); assert.ok(pass);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('should provide additional arguments to `func`', function(assert) { QUnit.test('should provide additional arguments to `func`', function(assert) {
@@ -3863,7 +3776,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var args; var args;
_.delay(function() { _.delay(function() {
@@ -3874,11 +3786,6 @@
assert.deepEqual(args, [1, 2]); assert.deepEqual(args, [1, 2]);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('should be cancelable', function(assert) { QUnit.test('should be cancelable', function(assert) {
@@ -3886,7 +3793,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var pass = true; var pass = true;
var timerId = _.delay(function() { var timerId = _.delay(function() {
@@ -3899,11 +3805,6 @@
assert.ok(pass); assert.ok(pass);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert);
done();
}
}); });
}()); }());
@@ -13729,13 +13630,7 @@
if (!isModularize) { if (!isModularize) {
assert.strictEqual(_.noConflict(), oldDash); assert.strictEqual(_.noConflict(), oldDash);
if (!(isRhino && typeof require == 'function')) {
assert.notStrictEqual(root._, oldDash); assert.notStrictEqual(root._, oldDash);
}
else {
skipTest(assert);
}
root._ = oldDash; root._ = oldDash;
} }
else { else {
@@ -13779,16 +13674,10 @@
assert.ok(actual >= stamp); assert.ok(actual >= stamp);
if (!(isRhino && isModularize)) {
setTimeout(function() { setTimeout(function() {
assert.ok(_.now() > actual); assert.ok(_.now() > actual);
done(); done();
}, 32); }, 32);
}
else {
skipTest(assert);
done();
}
}); });
}()); }());
@@ -19119,7 +19008,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
throttled = _.throttle(function() { callCount++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
@@ -19134,11 +19022,6 @@
assert.ok(callCount > lastCount); assert.ok(callCount > lastCount);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('subsequent calls should return the result of the first call', function(assert) { QUnit.test('subsequent calls should return the result of the first call', function(assert) {
@@ -19146,7 +19029,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var throttled = _.throttle(identity, 32), var throttled = _.throttle(identity, 32),
result = [throttled('a'), throttled('b')]; result = [throttled('a'), throttled('b')];
@@ -19161,11 +19043,6 @@
assert.notStrictEqual(result[1], undefined); assert.notStrictEqual(result[1], undefined);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 5);
done();
}
}); });
QUnit.test('should clear timeout when `func` is called', function(assert) { QUnit.test('should clear timeout when `func` is called', function(assert) {
@@ -19213,7 +19090,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
throttled = _.throttle(function() { callCount++; }, 32); throttled = _.throttle(function() { callCount++; }, 32);
@@ -19224,11 +19100,6 @@
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
lodashStable.times(2, function(index) { lodashStable.times(2, function(index) {
@@ -19237,7 +19108,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0, var callCount = 0,
limit = (argv || isPhantom) ? 1000 : 320, limit = (argv || isPhantom) ? 1000 : 320,
options = index ? { 'leading': false } : {}; options = index ? { 'leading': false } : {};
@@ -19256,11 +19126,6 @@
assert.ok(actual); assert.ok(actual);
done(); done();
}, 1); }, 1);
}
else {
skipTest(assert);
done();
}
}); });
}); });
@@ -19269,7 +19134,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var throttled = _.throttle(function(value) { var throttled = _.throttle(function(value) {
@@ -19284,26 +19148,16 @@
assert.strictEqual(callCount, 2); assert.strictEqual(callCount, 2);
done(); done();
}, 128); }, 128);
}
else {
skipTest(assert, 3);
done();
}
}); });
QUnit.test('should support a `leading` option', function(assert) { QUnit.test('should support a `leading` option', function(assert) {
assert.expect(2); assert.expect(2);
if (!(isRhino && isModularize)) {
var withLeading = _.throttle(identity, 32, { 'leading': true }); var withLeading = _.throttle(identity, 32, { 'leading': true });
assert.strictEqual(withLeading('a'), 'a'); assert.strictEqual(withLeading('a'), 'a');
var withoutLeading = _.throttle(identity, 32, { 'leading': false }); var withoutLeading = _.throttle(identity, 32, { 'leading': false });
assert.strictEqual(withoutLeading('a'), undefined); assert.strictEqual(withoutLeading('a'), undefined);
}
else {
skipTest(assert, 2);
}
}); });
QUnit.test('should support a `trailing` option', function(assert) { QUnit.test('should support a `trailing` option', function(assert) {
@@ -19311,7 +19165,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var withCount = 0, var withCount = 0,
withoutCount = 0; withoutCount = 0;
@@ -19336,11 +19189,6 @@
assert.strictEqual(withoutCount, 1); assert.strictEqual(withoutCount, 1);
done(); done();
}, 256); }, 256);
}
else {
skipTest(assert, 6);
done();
}
}); });
QUnit.test('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function(assert) { QUnit.test('should not update `lastCalled`, at the end of the timeout, when `trailing` is `false`', function(assert) {
@@ -19348,7 +19196,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var throttled = _.throttle(function() { var throttled = _.throttle(function() {
@@ -19367,11 +19214,6 @@
assert.ok(callCount > 1); assert.ok(callCount > 1);
done(); done();
}, 192); }, 192);
}
else {
skipTest(assert);
done();
}
}); });
}()); }());
@@ -19401,7 +19243,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var funced = func(function() { var funced = func(function() {
@@ -19415,11 +19256,6 @@
assert.strictEqual(callCount, isDebounce ? 1 : 2); assert.strictEqual(callCount, isDebounce ? 1 : 2);
done(); done();
}, 32); }, 32);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('_.' + methodName + ' should invoke `func` with the correct `this` binding', function(assert) { QUnit.test('_.' + methodName + ' should invoke `func` with the correct `this` binding', function(assert) {
@@ -19427,7 +19263,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var object = { var object = {
'funced': func(function() { actual.push(this); }, 32) 'funced': func(function() { actual.push(this); }, 32)
}; };
@@ -19443,11 +19278,6 @@
assert.deepEqual(actual, expected); assert.deepEqual(actual, expected);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('_.' + methodName + ' supports recursive calls', function(assert) { QUnit.test('_.' + methodName + ' supports recursive calls', function(assert) {
@@ -19455,7 +19285,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var actual = [], var actual = [],
args = lodashStable.map(['a', 'b', 'c'], function(chr) { return [{}, chr]; }), args = lodashStable.map(['a', 'b', 'c'], function(chr) { return [{}, chr]; }),
expected = args.slice(), expected = args.slice(),
@@ -19480,11 +19309,6 @@
assert.deepEqual(actual, expected.slice(0, actual.length)); assert.deepEqual(actual, expected.slice(0, actual.length));
done(); done();
}, 256); }, 256);
}
else {
skipTest(assert, 2);
done();
}
}); });
QUnit.test('_.' + methodName + ' should work if the system time is set backwards', function(assert) { QUnit.test('_.' + methodName + ' should work if the system time is set backwards', function(assert) {
@@ -19531,7 +19355,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var funced = func(function() { var funced = func(function() {
@@ -19545,11 +19368,6 @@
assert.strictEqual(callCount, 0); assert.strictEqual(callCount, 0);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert);
done();
}
}); });
QUnit.test('_.' + methodName + ' should reset `lastCalled` after cancelling', function(assert) { QUnit.test('_.' + methodName + ' should reset `lastCalled` after cancelling', function(assert) {
@@ -19557,7 +19375,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var funced = func(function() { var funced = func(function() {
@@ -19572,11 +19389,6 @@
assert.strictEqual(callCount, 2); assert.strictEqual(callCount, 2);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 3);
done();
}
}); });
QUnit.test('_.' + methodName + ' should support flushing delayed calls', function(assert) { QUnit.test('_.' + methodName + ' should support flushing delayed calls', function(assert) {
@@ -19584,7 +19396,6 @@
var done = assert.async(); var done = assert.async();
if (!(isRhino && isModularize)) {
var callCount = 0; var callCount = 0;
var funced = func(function() { var funced = func(function() {
@@ -19599,11 +19410,6 @@
assert.strictEqual(callCount, 1); assert.strictEqual(callCount, 1);
done(); done();
}, 64); }, 64);
}
else {
skipTest(assert, 2);
done();
}
}); });
}); });