mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix compile output tests in Firefox 12 with Coffee
This commit is contained in:
@@ -40,220 +40,14 @@ Tinytest.add("spacebars-compiler - compiler output", function (test) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
run("abc",
|
||||
function () {
|
||||
var view = this;
|
||||
return "abc";
|
||||
});
|
||||
|
||||
run("{{foo}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{foo bar}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"),
|
||||
view.lookup("bar"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{foo x=bar}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"), Spacebars.kw({
|
||||
x: view.lookup("bar")
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{foo.bar baz}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(Spacebars.dot(
|
||||
view.lookup("foo"), "bar"),
|
||||
view.lookup("baz"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{foo bar.baz}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"),
|
||||
Spacebars.dot(view.lookup("bar"), "baz"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{foo x=bar.baz}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"), Spacebars.kw({
|
||||
x: Spacebars.dot(view.lookup("bar"), "baz")
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{#foo}}abc{{/foo}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.include(view.lookupTemplate("foo"), (function() {
|
||||
return "abc";
|
||||
}));
|
||||
});
|
||||
|
||||
run("{{#if cond}}aaa{{else}}bbb{{/if}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.If(function () {
|
||||
return Spacebars.call(view.lookup("cond"));
|
||||
}, (function() {
|
||||
return "aaa";
|
||||
}), (function() {
|
||||
return "bbb";
|
||||
}));
|
||||
});
|
||||
|
||||
run("{{!-- --}}{{#if cond}}aaa{{!\n}}{{else}}{{!}}bbb{{!-- --}}{{/if}}{{!}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.If(function () {
|
||||
return Spacebars.call(view.lookup("cond"));
|
||||
}, (function() {
|
||||
return "aaa";
|
||||
}), (function() {
|
||||
return "bbb";
|
||||
}));
|
||||
});
|
||||
|
||||
run("{{> foo bar}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.call(view.lookup("bar"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{> foo x=bar}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return {
|
||||
x: Spacebars.call(view.lookup("bar"))
|
||||
};
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
run("{{> foo bar.baz}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.call(Spacebars.dot(view.lookup("bar"), "baz"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{> foo x=bar.baz}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return {
|
||||
x: Spacebars.call(Spacebars.dot(view.lookup("bar"), "baz"))
|
||||
};
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{> foo bar baz}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.dataMustache(view.lookup("bar"), view.lookup("baz"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
run("{{#foo bar baz}}aaa{{/foo}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.dataMustache(view.lookup("bar"), view.lookup("baz"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"), (function() {
|
||||
return "aaa";
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
run("{{#foo p.q r.s}}aaa{{/foo}}",
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.dataMustache(Spacebars.dot(view.lookup("p"), "q"), Spacebars.dot(view.lookup("r"), "s"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"), (function() {
|
||||
return "aaa";
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
run("<a {{b}}></a>",
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.A(HTML.Attrs(function() {
|
||||
return Spacebars.attrMustache(view.lookup("b"));
|
||||
}));
|
||||
});
|
||||
|
||||
run("<a {{b}} c=d{{e}}f></a>",
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.A(HTML.Attrs({
|
||||
c: (function() { return [
|
||||
"d",
|
||||
Spacebars.mustache(view.lookup("e")),
|
||||
"f" ]; })
|
||||
}, function() {
|
||||
return Spacebars.attrMustache(view.lookup("b"));
|
||||
}));
|
||||
});
|
||||
|
||||
run("<asdf>{{foo}}</asdf>",
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.getTag("asdf")(Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"));
|
||||
}));
|
||||
});
|
||||
|
||||
run("<textarea>{{foo}}</textarea>",
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.TEXTAREA({value: (function () {
|
||||
return Spacebars.mustache(view.lookup("foo"));
|
||||
}) });
|
||||
});
|
||||
coffee.runCompilerOutputTests(run);
|
||||
});
|
||||
|
||||
coffee = {
|
||||
runCompilerOutputTests: null // implemented in compiler_output_tests.coffee
|
||||
};
|
||||
|
||||
|
||||
Tinytest.add("spacebars-compiler - compiler errors", function (test) {
|
||||
|
||||
var getError = function (input) {
|
||||
|
||||
253
packages/spacebars-compiler/compiler_output_tests.coffee
Normal file
253
packages/spacebars-compiler/compiler_output_tests.coffee
Normal file
@@ -0,0 +1,253 @@
|
||||
coffee.runCompilerOutputTests = (run) ->
|
||||
run "abc",
|
||||
"""
|
||||
function () {
|
||||
var view = this;
|
||||
return "abc";
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{foo}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{foo bar}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"),
|
||||
view.lookup("bar"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{foo x=bar}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"), Spacebars.kw({
|
||||
x: view.lookup("bar")
|
||||
}));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{foo.bar baz}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(Spacebars.dot(
|
||||
view.lookup("foo"), "bar"),
|
||||
view.lookup("baz"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{foo bar.baz}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"),
|
||||
Spacebars.dot(view.lookup("bar"), "baz"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{foo x=bar.baz}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"), Spacebars.kw({
|
||||
x: Spacebars.dot(view.lookup("bar"), "baz")
|
||||
}));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{#foo}}abc{{/foo}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.include(view.lookupTemplate("foo"), (function() {
|
||||
return "abc";
|
||||
}));
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{#if cond}}aaa{{else}}bbb{{/if}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.If(function () {
|
||||
return Spacebars.call(view.lookup("cond"));
|
||||
}, (function() {
|
||||
return "aaa";
|
||||
}), (function() {
|
||||
return "bbb";
|
||||
}));
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{!-- --}}{{#if cond}}aaa{{!\n}}{{else}}{{!}}bbb{{!-- --}}{{/if}}{{!}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Blaze.If(function () {
|
||||
return Spacebars.call(view.lookup("cond"));
|
||||
}, (function() {
|
||||
return "aaa";
|
||||
}), (function() {
|
||||
return "bbb";
|
||||
}));
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{> foo bar}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.call(view.lookup("bar"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{> foo x=bar}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return {
|
||||
x: Spacebars.call(view.lookup("bar"))
|
||||
};
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
run "{{> foo bar.baz}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.call(Spacebars.dot(view.lookup("bar"), "baz"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{> foo x=bar.baz}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return {
|
||||
x: Spacebars.call(Spacebars.dot(view.lookup("bar"), "baz"))
|
||||
};
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{> foo bar baz}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.dataMustache(view.lookup("bar"), view.lookup("baz"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"));
|
||||
});
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
run "{{#foo bar baz}}aaa{{/foo}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.dataMustache(view.lookup("bar"), view.lookup("baz"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"), (function() {
|
||||
return "aaa";
|
||||
}));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "{{#foo p.q r.s}}aaa{{/foo}}",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return Spacebars.TemplateWith(function() {
|
||||
return Spacebars.dataMustache(Spacebars.dot(view.lookup("p"), "q"), Spacebars.dot(view.lookup("r"), "s"));
|
||||
}, function() {
|
||||
return Spacebars.include(view.lookupTemplate("foo"), (function() {
|
||||
return "aaa";
|
||||
}));
|
||||
});
|
||||
}
|
||||
"""
|
||||
|
||||
run "<a {{b}}></a>",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.A(HTML.Attrs(function() {
|
||||
return Spacebars.attrMustache(view.lookup("b"));
|
||||
}));
|
||||
}
|
||||
"""
|
||||
|
||||
run "<a {{b}} c=d{{e}}f></a>",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.A(HTML.Attrs({
|
||||
c: (function() { return [
|
||||
"d",
|
||||
Spacebars.mustache(view.lookup("e")),
|
||||
"f" ]; })
|
||||
}, function() {
|
||||
return Spacebars.attrMustache(view.lookup("b"));
|
||||
}));
|
||||
}
|
||||
"""
|
||||
|
||||
run "<asdf>{{foo}}</asdf>",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.getTag("asdf")(Blaze.View(function() {
|
||||
return Spacebars.mustache(view.lookup("foo"));
|
||||
}));
|
||||
}
|
||||
"""
|
||||
|
||||
run "<textarea>{{foo}}</textarea>",
|
||||
"""
|
||||
function() {
|
||||
var view = this;
|
||||
return HTML.TEXTAREA({value: (function () {
|
||||
return Spacebars.mustache(view.lookup("foo"));
|
||||
}) });
|
||||
}
|
||||
"""
|
||||
@@ -22,6 +22,8 @@ Package.on_test(function (api) {
|
||||
api.use('spacebars-compiler');
|
||||
api.use('tinytest');
|
||||
api.use('blaze-tools');
|
||||
api.use('coffeescript');
|
||||
api.add_files('spacebars_tests.js');
|
||||
api.add_files('compile_tests.js');
|
||||
api.add_files('compiler_output_tests.coffee');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user