Update literal ast nodes for new spec

This commit is contained in:
kpdecker
2014-11-26 19:22:09 -06:00
parent 2a4819d75c
commit 697bbe59ca
7 changed files with 41 additions and 43 deletions
+12 -11
View File
@@ -1,3 +1,4 @@
/*global CompilerContext */
describe('string params mode', function() {
it("arguments to helpers can be retrieved from options hash in string form", function() {
var template = CompilerContext.compile('{{wycats is.a slave.driver}}', {stringParams: true});
@@ -56,9 +57,9 @@ describe('string params mode', function() {
var helpers = {
tomdale: function(desire, noun, trueBool, falseBool, options) {
equal(options.types[0], 'STRING', "the string type is passed");
equal(options.types[0], 'StringLiteral', "the string type is passed");
equal(options.types[1], 'ID', "the expression type is passed");
equal(options.types[2], 'BOOLEAN', "the expression type is passed");
equal(options.types[2], 'BooleanLiteral', "the expression type is passed");
equal(desire, "need", "the string form is passed for strings");
equal(noun, "dad.joke", "the string form is passed for expressions");
equal(trueBool, true, "raw booleans are passed through");
@@ -76,21 +77,21 @@ describe('string params mode', function() {
var helpers = {
tomdale: function(exclamation, options) {
equal(exclamation, "he.says");
equal(options.types[0], "ID");
equal(exclamation, 'he.says');
equal(options.types[0], 'ID');
equal(options.hashTypes.desire, "STRING");
equal(options.hashTypes.noun, "ID");
equal(options.hashTypes.bool, "BOOLEAN");
equal(options.hash.desire, "need");
equal(options.hash.noun, "dad.joke");
equal(options.hashTypes.desire, 'StringLiteral');
equal(options.hashTypes.noun, 'ID');
equal(options.hashTypes.bool, 'BooleanLiteral');
equal(options.hash.desire, 'need');
equal(options.hash.noun, 'dad.joke');
equal(options.hash.bool, true);
return "Helper called";
return 'Helper called';
}
};
var result = template({}, { helpers: helpers });
equal(result, "Helper called");
equal(result, 'Helper called');
});
it("hash parameters get context information", function() {
+6 -6
View File
@@ -20,14 +20,14 @@ describe('Visitor', function() {
it('should traverse to stubs', function() {
var visitor = new Handlebars.Visitor();
visitor.STRING = function(string) {
equal(string.string, '2');
visitor.StringLiteral = function(string) {
equal(string.value, '2');
};
visitor.NUMBER = function(number) {
equal(number.stringModeValue, 1);
visitor.NumberLiteral = function(number) {
equal(number.value, 1);
};
visitor.BOOLEAN = function(bool) {
equal(bool.stringModeValue, true);
visitor.BooleanLiteral = function(bool) {
equal(bool.value, true);
};
visitor.ID = function(id) {
equal(id.original, 'foo.bar');