diff options
Diffstat (limited to 'spec/parser_spec.rb')
-rw-r--r-- | spec/parser_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/parser_spec.rb b/spec/parser_spec.rb index d9187ce..9997027 100644 --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -411,4 +411,23 @@ describe "Parser" do it "knows how to report the correct line number in errors when the first character is a newline" do lambda { ast_for("\n\nhello\n\nmy\n\n{{foo}") }.should raise_error(V8::JSError, /Parse error on line 7/m) end + + context "externally compiled AST" do + + it "can pass through an already-compiled AST" do + ast_for(@context.eval('new Handlebars.AST.ProgramNode([ new Handlebars.AST.ContentNode("Hello")]);')).should == root do + content "Hello" + end + end + + it "can pass through an already-compiled AST via compile/precompile" do + @context = Handlebars::Spec::FULL_CONTEXT + + code = 'Handlebars.compile(new Handlebars.AST.ProgramNode([ new Handlebars.AST.ContentNode("Hello")]))();' + @context.eval(code).should == "Hello" + + code = @context.eval 'Handlebars.precompile(new Handlebars.AST.ProgramNode([ new Handlebars.AST.ContentNode("Hello")]))' + @context.eval("(#{code})(this)").should == "Hello" + end + end end |