Improve compiling infrastructure, and restore a bit of duplication in spec_helper to make debugging easier in test failures

This commit is contained in:
wycats
2010-12-11 18:10:26 -08:00
parent 35b4d9fd01
commit fdc8e425d0
2 changed files with 22 additions and 2 deletions
+21 -1
View File
@@ -37,9 +37,29 @@ module Handlebars
end
end
def self.remove_exports(string)
match = string.match(%r{^// BEGIN\(BROWSER\)\n(.*)\n^// END\(BROWSER\)}m)
match ? match[1] : string
end
def self.js_load(file)
str = File.read(file)
CONTEXT.eval(remove_exports(str), file)
end
CONTEXT = V8::Context.new
CONTEXT.instance_eval do |context|
context.load('dist/handlebars.debug.js')
context["exports"] = nil
context["Handlebars"] = {}
Handlebars::Spec.js_load('lib/handlebars/ast.js');
Handlebars::Spec.js_load('lib/handlebars/jison_ext.js');
Handlebars::Spec.js_load('lib/handlebars/handlebars_lexer.js')
Handlebars::Spec.js_load('lib/handlebars/printer.js')
Handlebars::Spec.js_load('lib/handlebars/parser.js')
Handlebars::Spec.js_load('lib/handlebars/runtime.js')
Handlebars::Spec.js_load('lib/handlebars/utils.js')
Handlebars::Spec.js_load('lib/handlebars.js')
context["p"] = proc do |val|
p val