Add some more tests, and properly handle errors across the boundary in tests
This commit is contained in:
@@ -67,7 +67,7 @@ Handlebars.PrintVisitor.prototype.mustache = function(mustache) {
|
||||
}
|
||||
|
||||
var params = "[" + paramStrings.join(", ") + "]";
|
||||
return this.pad("{{ " + this.accept(mustache.id) + " " + params + "}}");
|
||||
return this.pad("{{ " + this.accept(mustache.id) + " " + params + " }}");
|
||||
};
|
||||
|
||||
Handlebars.PrintVisitor.prototype.partial = function(partial) {
|
||||
@@ -75,7 +75,7 @@ Handlebars.PrintVisitor.prototype.partial = function(partial) {
|
||||
};
|
||||
|
||||
Handlebars.PrintVisitor.prototype.STRING = function(string) {
|
||||
return string.string;
|
||||
return '"' + string.string + '"';
|
||||
};
|
||||
|
||||
Handlebars.PrintVisitor.prototype.ID = function(id) {
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
require "v8"
|
||||
|
||||
# Monkey patches due to bugs in RubyRacer
|
||||
class V8::JSError
|
||||
def initialize(try, to)
|
||||
@to = to
|
||||
begin
|
||||
super(initialize_unsafe(try))
|
||||
rescue Exception => e
|
||||
# Original code does not make an Array here
|
||||
@boundaries = [Boundary.new(:rbframes => e.backtrace)]
|
||||
@value = e
|
||||
super("BUG! please report. JSError#initialize failed!: #{e.message}")
|
||||
end
|
||||
end
|
||||
|
||||
def parse_js_frames(try)
|
||||
raw = @to.rb(try.StackTrace())
|
||||
if raw && !raw.empty?
|
||||
raw.split("\n")[1..-1].tap do |frames|
|
||||
# Original code uses strip!, and the frames are not guaranteed to be strippable
|
||||
frames.each {|frame| frame.strip.chomp!(",")}
|
||||
end
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.before(:all) do
|
||||
@context = V8::Context.new
|
||||
|
||||
@@ -117,11 +117,11 @@ describe "Tokenizer" do
|
||||
result[2].should be_token("STRING", %{bar"baz})
|
||||
end
|
||||
|
||||
it "does not time out with broken input" do
|
||||
lambda do
|
||||
Timeout.timeout(1) do
|
||||
tokenize("{{foo}")
|
||||
it "does not time out in a mustache with a single } followed by EOF" do
|
||||
Timeout.timeout(1) { tokenize("{{foo}").should match_tokens(%w(OPEN ID)) }
|
||||
end
|
||||
end.should_not raise_error(Timeout::Error)
|
||||
|
||||
it "does not time out in a mustache when invalid ID characters are used" do
|
||||
Timeout.timeout(1) { tokenize("{{foo & }}").should match_tokens(%w(OPEN ID)) }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user