Fix failing build tests.

Former-commit-id: c4673ee77f6750500e0f0a1adaf359108db89932
This commit is contained in:
John-David Dalton
2013-06-23 00:30:38 -07:00
parent 9c07c7fe4f
commit e222bc631a
2 changed files with 69 additions and 83 deletions

View File

@@ -3333,6 +3333,7 @@
// inline all functions defined with `createIterator` // inline all functions defined with `createIterator`
_.functions(lodash).forEach(function(methodName) { _.functions(lodash).forEach(function(methodName) {
if (!(isUnderscore && isLodashMethod(methodName))) {
// strip leading underscores to match pseudo private functions // strip leading underscores to match pseudo private functions
var reFunc = RegExp('^( *)(var ' + methodName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n', 'm'); var reFunc = RegExp('^( *)(var ' + methodName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n', 'm');
if (reFunc.test(source)) { if (reFunc.test(source)) {
@@ -3342,6 +3343,7 @@
cleanupCompiled(getFunctionSource(lodash[methodName], indent)) + ';\n'; cleanupCompiled(getFunctionSource(lodash[methodName], indent)) + ';\n';
}); });
} }
}
}); });
if (isUnderscore) { if (isUnderscore) {
@@ -3423,7 +3425,7 @@
}()); }());
} }
} }
else {
source = removeFromCreateIterator(source, 'support'); source = removeFromCreateIterator(source, 'support');
// inline `iteratorTemplate` template // inline `iteratorTemplate` template
@@ -3460,9 +3462,11 @@
// remove comments, including sourceURLs // remove comments, including sourceURLs
snippet = snippet.replace(/\s*\/\/.*(?:\n|$)/g, ''); snippet = snippet.replace(/\s*\/\/.*(?:\n|$)/g, '');
return indent + 'var iteratorTemplate = ' + snippet + ';\n'; // replace `iteratorTemplate` assignment
snippet = indent + 'var iteratorTemplate = ' + snippet + ';\n';
return snippet;
}); });
}
// remove methods from the build // remove methods from the build
allMethods.forEach(function(otherName) { allMethods.forEach(function(otherName) {
@@ -3597,6 +3601,9 @@
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1'); source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
} }
if (isNoDep) { if (isNoDep) {
// remove all horizontal rule comment separators
source = source.replace(/^ *\/\*-+\*\/\n/gm, '');
_.each(buildMethods, function(methodName) { _.each(buildMethods, function(methodName) {
_.each(getAliases(methodName), function(alias) { _.each(getAliases(methodName), function(alias) {
source = removeFunction(source, alias); source = removeFunction(source, alias);
@@ -3607,8 +3614,12 @@
source = removeVar(source, varName); source = removeVar(source, varName);
}); });
// remove all horizontal rule comment separators if (!isAMD && !isCommonJS && !isGlobal && !isNode) {
source = source.replace(/^ *\/\*-+\*\/\n/gm, ''); source = removeFunction(source, 'lodash');
source = removeLodashWrapper(source);
source = removePseudoPrivates(source);
source = removeMethodAssignments(source);
}
} }
else { else {
if (isExcluded('bind')) { if (isExcluded('bind')) {
@@ -3728,12 +3739,6 @@
if (_.size(source.match(/\bfreeExports\b/g)) < 2) { if (_.size(source.match(/\bfreeExports\b/g)) < 2) {
source = removeVar(source, 'freeExports'); source = removeVar(source, 'freeExports');
} }
if (!isAMD && !isCommonJS && !isGlobal && !isNode) {
source = removeFunction(source, 'lodash');
source = removeLodashWrapper(source);
source = removePseudoPrivates(source);
source = removeMethodAssignments(source);
}
debugSource = cleanupSource(source); debugSource = cleanupSource(source);
source = debugSource; source = debugSource;

View File

@@ -1363,16 +1363,11 @@
commands.forEach(function(command) { commands.forEach(function(command) {
asyncTest('`lodash modern include=each ' + command +'`', function() { asyncTest('`lodash modern include=each ' + command +'`', function() {
var start = _.after(2, _.once(QUnit.start)); var start = _.once(QUnit.start);
build(['-s', 'modern', 'include=each', command], function(data) { build(['-s', 'modern', 'include=each', command], function(data) {
var basename = path.basename(data.outputPath, '.js'), var basename = path.basename(data.outputPath, '.js');
context = createContext(); strictEqual(/function createCallback\b/.test(data.source), false, basename);
vm.runInContext(data.source, context);
var lodash = context._;
deepEqual(_.functions(lodash), ['each', 'forEach'], basename);
start(); start();
}); });
}); });
@@ -1582,12 +1577,11 @@
'include=each,filter,map', 'include=each,filter,map',
'include=once plus=bind,Chaining', 'include=once plus=bind,Chaining',
'category=collections,functions', 'category=collections,functions',
'backbone legacy category=utilities minus=first,last', 'backbone category=utilities minus=first,last',
'legacy include=defer', 'legacy include=defer',
'legacy underscore',
'modern strict include=isArguments,isArray,isFunction,isPlainObject,key', 'modern strict include=isArguments,isArray,isFunction,isPlainObject,key',
'underscore include=debounce,throttle plus=after minus=throttle', 'underscore include=debounce,throttle plus=after minus=throttle',
'underscore mobile strict category=functions exports=amd,global plus=pick,uniq', 'underscore strict category=functions exports=amd,global plus=pick,uniq',
] ]
.concat( .concat(
allMethods.map(function(methodName) { allMethods.map(function(methodName) {
@@ -1595,28 +1589,15 @@
}) })
); );
commands.forEach(function(origCommand) { var reNonCombinable = /\b(?:backbone|legacy|mobile|modern|underscore)\b/;
_.times(4, function(index) {
var command = origCommand;
if (index == 1) { commands.forEach(function(origCommand) {
if (/\b(?:legacy|mobile)\b/.test(command)) { _.each(['', 'mobile', 'modern', 'underscore'], function(otherCommand) {
var command = (otherCommand + ' ' + origCommand).trim();
if ((otherCommand && reNonCombinable.test(origCommand)) ||
(otherCommand == 'underscore' && /\bcategory\b/.test(origCommand))) {
return; return;
} }
command = 'mobile ' + command;
}
else if (index == 2) {
if (/\b(?:legacy|modern)\b/.test(command)) {
return;
}
command = 'modern ' + command;
}
else if (index == 3) {
if (/\b(?:category|legacy|underscore)\b/.test(command)) {
return;
}
command = 'underscore ' + command;
}
asyncTest('`lodash ' + command +'`', function() { asyncTest('`lodash ' + command +'`', function() {
var start = _.after(2, _.once(QUnit.start)); var start = _.after(2, _.once(QUnit.start));