Cleanup from code coverage report

This commit is contained in:
kpdecker
2014-08-23 17:44:45 -05:00
parent 84d646bb5d
commit cde008b49f
5 changed files with 43 additions and 16 deletions
+2 -2
View File
@@ -135,12 +135,12 @@ function isNextWhitespace(statements, i, isRoot) {
return checkWhitespace(isRoot, statements[i+1], statements[i+2]);
}
function checkWhitespace(isRoot, next1, next2, disallowIndent) {
function checkWhitespace(isRoot, next1, next2) {
if (!next1) {
return isRoot;
} else if (next1.type === 'content') {
// Check if the previous node is empty or whitespace only
if (disallowIndent ? !next1.string : /^[\s]*$/.test(next1.string)) {
if (/^[\s]*$/.test(next1.string)) {
if (next2) {
return next2.type === 'content' || /\n$/.test(next1.string);
} else {
+7 -11
View File
@@ -50,7 +50,7 @@ JavaScriptCompiler.prototype = {
compile: function(environment, options, context, asObject) {
this.environment = environment;
this.options = options || {};
this.options = options;
this.stringParams = this.options.stringParams;
this.trackIds = this.options.trackIds;
this.precompile = !asObject;
@@ -361,9 +361,9 @@ JavaScriptCompiler.prototype = {
return ' != null ? ' + lookup + ' : ' + current;
} else {
// Otherwise we can use generic falsy handling
return (falsy ? ' && ' : ' != null && ') + lookup;
return ' && ' + lookup;
}
}, true);
});
}
},
@@ -385,7 +385,7 @@ JavaScriptCompiler.prototype = {
for (var i = 0; i < len; i++) {
this.replaceStack(function(current) {
return ' && ' + this.nameLookup(current, parts[i], 'data');
}, true);
});
}
},
@@ -714,7 +714,7 @@ JavaScriptCompiler.prototype = {
return stack;
},
replaceStack: function(callback, chain) {
replaceStack: function(callback) {
var prefix = '',
inline = this.isInline(),
stack,
@@ -731,18 +731,14 @@ JavaScriptCompiler.prototype = {
if (top instanceof Literal) {
// Literals do not need to be inlined
stack = top.value;
prefix = stack = top.value;
usedLiteral = true;
if (chain) {
prefix = stack;
}
} else {
// Get or create the current stack name for use by the inline
createdStack = !this.stackSlot;
var name = !createdStack ? this.topStackName() : this.incrStack();
prefix = '(' + this.push(name) + ' = ' + top + (chain ? ')' : '),');
prefix = '(' + this.push(name) + ' = ' + top + ')';
stack = this.topStack();
}
+3 -3
View File
@@ -60,7 +60,7 @@ module.exports.cli = function(opts) {
output.push(opts.namespace);
output.push(' || {};\n');
}
function processTemplate(template, root, explicit) {
function processTemplate(template, root) {
var path = template,
stat = fs.statSync(path);
if (stat.isDirectory()) {
@@ -71,7 +71,7 @@ module.exports.cli = function(opts) {
processTemplate(path, root || template);
}
});
} else if (explicit || extension.test(path)) {
} else {
var data = fs.readFileSync(path, 'utf8');
if (opts.bom && data.indexOf('\uFEFF') === 0) {
@@ -112,7 +112,7 @@ module.exports.cli = function(opts) {
}
opts.templates.forEach(function(template) {
processTemplate(template, opts.root, true);
processTemplate(template, opts.root);
});
// Output the content
+30
View File
@@ -75,9 +75,39 @@ describe('precompiler', function() {
Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], amd: true, extension: 'handlebars'});
equal(/template\(amd\)/.test(log), true);
});
it('should output multiple amd', function() {
Handlebars.precompile = function() { return 'amd'; };
Precompiler.cli({templates: [__dirname + '/artifacts'], amd: true, extension: 'handlebars'});
equal(/return templates/.test(log), true);
equal(/template\(amd\)/.test(log), true);
});
it('should output amd partials', function() {
Handlebars.precompile = function() { return 'amd'; };
Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], amd: true, partial: true, extension: 'handlebars'});
equal(/return Handlebars\.partials\['empty'\]/.test(log), true);
equal(/template\(amd\)/.test(log), true);
});
it('should output multiple amd partials', function() {
Handlebars.precompile = function() { return 'amd'; };
Precompiler.cli({templates: [__dirname + '/artifacts'], amd: true, partial: true, extension: 'handlebars'});
equal(/return Handlebars\.partials\[/.test(log), false);
equal(/template\(amd\)/.test(log), true);
});
it('should output commonjs templates', function() {
Handlebars.precompile = function() { return 'commonjs'; };
Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], commonjs: true, extension: 'handlebars'});
equal(/template\(commonjs\)/.test(log), true);
});
it('should set data flag', function() {
Handlebars.precompile = function(data, options) { equal(options.data, true); return 'simple'; };
Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], simple: true, extension: 'handlebars', data: true});
equal(log, 'simple\n');
});
it('should set known helpers', function() {
Handlebars.precompile = function(data, options) { equal(options.knownHelpers.foo, true); return 'simple'; };
Precompiler.cli({templates: [__dirname + '/artifacts/empty.handlebars'], simple: true, extension: 'handlebars', known: 'foo'});
equal(log, 'simple\n');
});
});
+1
View File
@@ -1 +1,2 @@
/* jshint ignore:start */
/* istanbul ignore next */