diff options
author | tomhuda <tomhuda@strobecorp.com> | 2011-06-01 22:33:48 -0700 |
---|---|---|
committer | tomhuda <tomhuda@strobecorp.com> | 2011-06-01 22:33:48 -0700 |
commit | 0f78345d0c3399edd27b897485c7f190fe4e8bf6 (patch) | |
tree | 64f4be14a5d25349ad81b31ff9d3d729249daf27 /spec/parser_spec.rb | |
parent | 4eeda34ad2bd051b8d686f1b9086054f89284ec1 (diff) | |
download | handlebars.js-0f78345d0c3399edd27b897485c7f190fe4e8bf6.zip handlebars.js-0f78345d0c3399edd27b897485c7f190fe4e8bf6.tar.gz handlebars.js-0f78345d0c3399edd27b897485c7f190fe4e8bf6.tar.bz2 |
Add support for INTEGER expressions
Diffstat (limited to 'spec/parser_spec.rb')
-rw-r--r-- | spec/parser_spec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index 78ffa1e..941887d 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -92,6 +92,10 @@ describe "Parser" do string.inspect end + def integer(string) + "INTEGER{#{string}}" + end + def hash(*pairs) "HASH{" + pairs.map {|k,v| "#{k}=#{v}" }.join(", ") + "}" end @@ -127,7 +131,11 @@ describe "Parser" do it "parses mustaches with hash arguments" do ast_for("{{foo bar=baz}}").should == program do - mustache id("foo"), [], hash(["bar", "ID:baz"]) + mustache id("foo"), [], hash(["bar", id("baz")]) + end + + ast_for("{{foo bar=1}}").should == program do + mustache id("foo"), [], hash(["bar", integer("1")]) end ast_for("{{foo bar=baz bat=bam}}").should == program do @@ -141,12 +149,20 @@ describe "Parser" do ast_for("{{foo omg bar=baz bat=\"bam\"}}").should == program do mustache id("foo"), [id("omg")], hash(["bar", id("baz")], ["bat", string("bam")]) end + + ast_for("{{foo omg bar=baz bat=\"bam\" baz=1}}").should == program do + mustache id("foo"), [id("omg")], hash(["bar", id("baz")], ["bat", string("bam")], ["baz", integer("1")]) + end end it "parses mustaches with string parameters" do ast_for("{{foo bar \"baz\" }}").should == program { mustache id("foo"), [id("bar"), string("baz")] } end + it "parses mustaches with INTEGER parameters" do + ast_for("{{foo 1}}").should == program { mustache id("foo"), [integer("1")] } + end + it "parses contents followed by a mustache" do ast_for("foo bar {{baz}}").should == program do content "foo bar " |