From a0bc4dc3b6a5b7188578b4d9f2df4edb81fe14df Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 13 Apr 2011 14:42:30 -0700 Subject: [PATCH] Test that names are being processed in partials; fixed exception on attempt to use partials when unconfigured; moved partials tests down into a more sensible location among the tests. --- .../com/samskivert/mustache/MustacheTest.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/test/java/com/samskivert/mustache/MustacheTest.java b/src/test/java/com/samskivert/mustache/MustacheTest.java index cbed738..2920b34 100644 --- a/src/test/java/com/samskivert/mustache/MustacheTest.java +++ b/src/test/java/com/samskivert/mustache/MustacheTest.java @@ -21,20 +21,6 @@ import org.junit.Test; */ public class MustacheTest { - @Test(expected = IllegalArgumentException.class) - public void testDefaultTemplateIncludeBehavior () { - test(null, "{{>foo}}", null); - } - - @Test - public void testTemplateIncludeBehavior () { - test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() { - public Reader getTemplate (String name) { - return new StringReader("inside:{{bar}}"); - } - }), "foo inside:foo foo", "{{bar}} {{>foo}} {{bar}}", context("bar", "foo")); - } - @Test public void testSimpleVariable () { test("bar", "{{foo}}", context("foo", "bar")); } @@ -131,6 +117,23 @@ public class MustacheTest test("foobar", "foo{{! nothing to see here}}bar", new Object()); } + @Test(expected=UnsupportedOperationException.class) + public void testPartialUseWhenUnconfigured () { + test(null, "{{>foo}}", null); + } + + @Test public void testPartial () { + test(Mustache.compiler().withLoader(new Mustache.TemplateLoader() { + public Reader getTemplate (String name) { + if (name.equals("foo")) { + return new StringReader("inside:{{bar}}"); + } else { + return new StringReader("nonfoo"); + } + } + }), "foo inside:foo nonfoo foo", "{{bar}} {{>foo}} {{>baz}} {{bar}}", context("bar", "foo")); + } + @Test public void testUnescapeHTML () { assertEquals("", Mustache.compiler().escapeHTML(true).compile("{{&a}}"). execute(context("a", "")));