Make the IIFE Closure Compiler regexp in post process more restrictive to work better with the "iife" build option.

Former-commit-id: 999602451e50850eb82680b9c377d97605be8af4
This commit is contained in:
John-David Dalton
2012-09-13 01:40:28 -07:00
parent e69bdabc99
commit 13d901bf8d
3 changed files with 64 additions and 45 deletions

View File

@@ -551,20 +551,33 @@
QUnit.module('iife command');
(function() {
var start = _.after(2, _.once(QUnit.start));
var commands = [
'iife=this["lodash"]=(function(window,undefined){%output%;return lodash}(this))',
'iife=define(function(window,undefined){return function(){%output%;return lodash}}(this));'
];
asyncTest('`lodash iife=...`', function() {
build(['-s', 'exports=none', 'iife=this["lodash"]=(function(window,undefined){%output%;return lodash}(this))'], function(source, filepath) {
var basename = path.basename(filepath, '.js'),
context = createContext();
commands.forEach(function(command) {
var start = _.after(2, _.once(QUnit.start));
try {
vm.runInContext(source, context);
} catch(e) { }
asyncTest('`lodash ' + command +'`', function() {
build(['-s', 'exports=none', command], function(source, filepath) {
var basename = path.basename(filepath, '.js'),
context = createContext();
var lodash = context.lodash || {};
ok(_.isString(lodash.VERSION), basename);
start();
context.define = function(func) {
context.lodash = func();
};
try {
vm.runInContext(source, context);
} catch(e) {
console.log(e);
}
var lodash = context.lodash || {};
ok(_.isString(lodash.VERSION), basename);
start();
});
});
});
}());
@@ -621,7 +634,9 @@
try {
vm.runInContext(result, context);
} catch(e) { }
} catch(e) {
console.log(e);
}
var underscore = context._ || {};
ok(_.isString(underscore.VERSION));
@@ -646,7 +661,9 @@
try {
vm.runInContext(source, context);
} catch(e) { }
} catch(e) {
console.log(e);
}
var array = [1, 2, 3],
object1 = [{ 'a': 1 }],
@@ -712,7 +729,9 @@
try {
vm.runInContext(source, context);
} catch(e) { }
} catch(e) {
console.log(e);
}
if (/underscore/.test(command)) {
methodNames = underscoreMethods;