summaryrefslogtreecommitdiffstats
path: root/spec/visitor.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2015-01-18 17:27:27 -0600
committerkpdecker <kpdecker@gmail.com>2015-01-18 17:27:27 -0600
commit884bf1553663734f22ffcd9d758c9d71d4373bf9 (patch)
tree55d078077b9c23779858282dfe42dd3a42bd7c0d /spec/visitor.js
parent999da739a66199483ffc4d82426550aee5ac798f (diff)
downloadhandlebars.js-884bf1553663734f22ffcd9d758c9d71d4373bf9.zip
handlebars.js-884bf1553663734f22ffcd9d758c9d71d4373bf9.tar.gz
handlebars.js-884bf1553663734f22ffcd9d758c9d71d4373bf9.tar.bz2
Avoid direct references to sexpr in statements
This allows us to avoid creating unnecessary AST nodes and avoids things like isHelper. Side effect of these changes is that @data functions can now have data parameters passed to them.
Diffstat (limited to 'spec/visitor.js')
-rw-r--r--spec/visitor.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/spec/visitor.js b/spec/visitor.js
index 0c23c0d..3217230 100644
--- a/spec/visitor.js
+++ b/spec/visitor.js
@@ -24,11 +24,10 @@ describe('Visitor', function() {
visitor.BooleanLiteral = function(bool) {
equal(bool.value, true);
- equal(this.parents.length, 4);
+ equal(this.parents.length, 3);
equal(this.parents[0].type, 'SubExpression');
- equal(this.parents[1].type, 'SubExpression');
- equal(this.parents[2].type, 'BlockStatement');
- equal(this.parents[3].type, 'Program');
+ equal(this.parents[1].type, 'BlockStatement');
+ equal(this.parents[2].type, 'Program');
};
visitor.PathExpression = function(id) {
equal(/(foo\.)?bar$/.test(id.original), true);
@@ -84,26 +83,26 @@ describe('Visitor', function() {
var visitor = new Handlebars.Visitor();
visitor.mutating = true;
- visitor.SubExpression = function() {
+ visitor.PathExpression = function() {
return false;
};
var ast = Handlebars.parse('{{foo 42}}');
visitor.accept(ast);
- }, Handlebars.Exception, 'MustacheStatement requires sexpr');
+ }, Handlebars.Exception, 'MustacheStatement requires path');
});
it('should throw when returning non-node responses', function() {
shouldThrow(function() {
var visitor = new Handlebars.Visitor();
visitor.mutating = true;
- visitor.SubExpression = function() {
+ visitor.PathExpression = function() {
return {};
};
var ast = Handlebars.parse('{{foo 42}}');
visitor.accept(ast);
- }, Handlebars.Exception, 'Unexpected node type "undefined" found when accepting sexpr on MustacheStatement');
+ }, Handlebars.Exception, 'Unexpected node type "undefined" found when accepting path on MustacheStatement');
});
});
describe('arrays', function() {