mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Re-order test-build unit tests and make the iife test a bit more thorough.
Former-commit-id: f798639cfa58241b052d16b9ca6fbf4537482349
This commit is contained in:
@@ -418,103 +418,6 @@
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('lodash build');
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var commands = [
|
|
||||||
'backbone',
|
|
||||||
'csp',
|
|
||||||
'legacy',
|
|
||||||
'mobile',
|
|
||||||
'strict',
|
|
||||||
'underscore',
|
|
||||||
'category=arrays',
|
|
||||||
'category=chaining',
|
|
||||||
'category=collections',
|
|
||||||
'category=functions',
|
|
||||||
'category=objects',
|
|
||||||
'category=utilities',
|
|
||||||
'exclude=union,uniq,zip',
|
|
||||||
'include=each,filter,map',
|
|
||||||
'category=collections,functions',
|
|
||||||
'underscore backbone',
|
|
||||||
'backbone legacy category=utilities exclude=first,last',
|
|
||||||
'underscore mobile strict category=functions exports=amd,global include=pick,uniq',
|
|
||||||
]
|
|
||||||
.concat(
|
|
||||||
allMethods.map(function(methodName) {
|
|
||||||
return 'include=' + methodName;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
commands.forEach(function(command) {
|
|
||||||
var start = _.after(2, _.once(QUnit.start));
|
|
||||||
|
|
||||||
asyncTest('`lodash ' + command +'`', function() {
|
|
||||||
build(['--silent'].concat(command.split(' ')), function(source, filepath) {
|
|
||||||
var basename = path.basename(filepath, '.js'),
|
|
||||||
context = createContext(),
|
|
||||||
methodNames = [];
|
|
||||||
|
|
||||||
try {
|
|
||||||
vm.runInContext(source, context);
|
|
||||||
} catch(e) { }
|
|
||||||
|
|
||||||
if (/underscore/.test(command)) {
|
|
||||||
methodNames = underscoreMethods;
|
|
||||||
}
|
|
||||||
if (/backbone/.test(command)) {
|
|
||||||
methodNames = backboneDependencies;
|
|
||||||
}
|
|
||||||
if (/include/.test(command)) {
|
|
||||||
methodNames = methodNames.concat(command.match(/include=(\S*)/)[1].split(/, */));
|
|
||||||
}
|
|
||||||
if (/category/.test(command)) {
|
|
||||||
methodNames = command.match(/category=(\S*)/)[1].split(/, */).reduce(function(result, category) {
|
|
||||||
switch (category) {
|
|
||||||
case 'arrays':
|
|
||||||
return result.concat(arraysMethods);
|
|
||||||
case 'chaining':
|
|
||||||
return result.concat(chainingMethods);
|
|
||||||
case 'collections':
|
|
||||||
return result.concat(collectionsMethods);
|
|
||||||
case 'functions':
|
|
||||||
return result.concat(functionsMethods);
|
|
||||||
case 'objects':
|
|
||||||
return result.concat(objectsMethods);
|
|
||||||
case 'utilities':
|
|
||||||
return result.concat(utilityMethods);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}, methodNames);
|
|
||||||
}
|
|
||||||
if (!methodNames.length) {
|
|
||||||
methodNames = allMethods;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/exclude/.test(command)) {
|
|
||||||
methodNames = _.without.apply(_, [methodNames].concat(
|
|
||||||
expandMethodNames(command.match(/exclude=(\S*)/)[1].split(/, */))
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
methodNames = expandMethodNames(methodNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
var lodash = context._ || {};
|
|
||||||
methodNames = _.unique(methodNames);
|
|
||||||
|
|
||||||
methodNames.forEach(function(methodName) {
|
|
||||||
testMethod(lodash, methodName, basename);
|
|
||||||
});
|
|
||||||
|
|
||||||
start();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}());
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
QUnit.module('strict modifier');
|
QUnit.module('strict modifier');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
@@ -647,7 +550,7 @@
|
|||||||
var start = _.after(2, _.once(QUnit.start));
|
var start = _.after(2, _.once(QUnit.start));
|
||||||
|
|
||||||
asyncTest('`lodash iife=...`', function() {
|
asyncTest('`lodash iife=...`', function() {
|
||||||
build(['-s', 'iife=!function(window,undefined){%output%}(this)'], function(source, filepath) {
|
build(['-s', 'exports=none', 'iife=this["lodash"]=(function(window,undefined){%output%;return lodash}(this))'], function(source, filepath) {
|
||||||
var basename = path.basename(filepath, '.js'),
|
var basename = path.basename(filepath, '.js'),
|
||||||
context = createContext();
|
context = createContext();
|
||||||
|
|
||||||
@@ -655,9 +558,8 @@
|
|||||||
vm.runInContext(source, context);
|
vm.runInContext(source, context);
|
||||||
} catch(e) { }
|
} catch(e) { }
|
||||||
|
|
||||||
var lodash = context._ || {};
|
var lodash = context.lodash || {};
|
||||||
ok(_.isString(lodash.VERSION), basename);
|
ok(_.isString(lodash.VERSION), basename);
|
||||||
ok(/!function/.test(source), basename);
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -764,4 +666,101 @@
|
|||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
QUnit.module('lodash build');
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var commands = [
|
||||||
|
'backbone',
|
||||||
|
'csp',
|
||||||
|
'legacy',
|
||||||
|
'mobile',
|
||||||
|
'strict',
|
||||||
|
'underscore',
|
||||||
|
'category=arrays',
|
||||||
|
'category=chaining',
|
||||||
|
'category=collections',
|
||||||
|
'category=functions',
|
||||||
|
'category=objects',
|
||||||
|
'category=utilities',
|
||||||
|
'exclude=union,uniq,zip',
|
||||||
|
'include=each,filter,map',
|
||||||
|
'category=collections,functions',
|
||||||
|
'underscore backbone',
|
||||||
|
'backbone legacy category=utilities exclude=first,last',
|
||||||
|
'underscore mobile strict category=functions exports=amd,global include=pick,uniq',
|
||||||
|
]
|
||||||
|
.concat(
|
||||||
|
allMethods.map(function(methodName) {
|
||||||
|
return 'include=' + methodName;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
commands.forEach(function(command) {
|
||||||
|
var start = _.after(2, _.once(QUnit.start));
|
||||||
|
|
||||||
|
asyncTest('`lodash ' + command +'`', function() {
|
||||||
|
build(['--silent'].concat(command.split(' ')), function(source, filepath) {
|
||||||
|
var basename = path.basename(filepath, '.js'),
|
||||||
|
context = createContext(),
|
||||||
|
methodNames = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
vm.runInContext(source, context);
|
||||||
|
} catch(e) { }
|
||||||
|
|
||||||
|
if (/underscore/.test(command)) {
|
||||||
|
methodNames = underscoreMethods;
|
||||||
|
}
|
||||||
|
if (/backbone/.test(command)) {
|
||||||
|
methodNames = backboneDependencies;
|
||||||
|
}
|
||||||
|
if (/include/.test(command)) {
|
||||||
|
methodNames = methodNames.concat(command.match(/include=(\S*)/)[1].split(/, */));
|
||||||
|
}
|
||||||
|
if (/category/.test(command)) {
|
||||||
|
methodNames = command.match(/category=(\S*)/)[1].split(/, */).reduce(function(result, category) {
|
||||||
|
switch (category) {
|
||||||
|
case 'arrays':
|
||||||
|
return result.concat(arraysMethods);
|
||||||
|
case 'chaining':
|
||||||
|
return result.concat(chainingMethods);
|
||||||
|
case 'collections':
|
||||||
|
return result.concat(collectionsMethods);
|
||||||
|
case 'functions':
|
||||||
|
return result.concat(functionsMethods);
|
||||||
|
case 'objects':
|
||||||
|
return result.concat(objectsMethods);
|
||||||
|
case 'utilities':
|
||||||
|
return result.concat(utilityMethods);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}, methodNames);
|
||||||
|
}
|
||||||
|
if (!methodNames.length) {
|
||||||
|
methodNames = allMethods;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/exclude/.test(command)) {
|
||||||
|
methodNames = _.without.apply(_, [methodNames].concat(
|
||||||
|
expandMethodNames(command.match(/exclude=(\S*)/)[1].split(/, */))
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
methodNames = expandMethodNames(methodNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
var lodash = context._ || {};
|
||||||
|
methodNames = _.unique(methodNames);
|
||||||
|
|
||||||
|
methodNames.forEach(function(methodName) {
|
||||||
|
testMethod(lodash, methodName, basename);
|
||||||
|
});
|
||||||
|
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}());
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|||||||
Reference in New Issue
Block a user