Minor formatting tweaks made while reading diffs.

This commit is contained in:
Michael Bayne
2023-11-28 14:43:11 -08:00
parent fe6ef9c75d
commit 92c1222d80
8 changed files with 69 additions and 94 deletions
@@ -1,3 +1,7 @@
//
// JMustache - A Java implementation of the Mustache templating language
// http://github.com/samskivert/jmustache/blob/master/LICENSE
package com.samskivert.mustache;
import static org.junit.Assert.assertEquals;
@@ -19,13 +23,12 @@ import org.junit.Test;
import com.samskivert.mustache.Mustache.TemplateLoader;
public class PartialThreadSafeTest {
@Test
public void testPartialThreadSafe() throws Exception {
long t = System.currentTimeMillis();
AtomicInteger loadCount = new AtomicInteger();
TemplateLoader loader = new TemplateLoader() {
@Override
public Reader getTemplate(String name) throws Exception {
if ("partial".equals(name)) {
@@ -63,7 +66,5 @@ public class PartialThreadSafeTest {
assertEquals(1, loadCount.get());
System.out.println(loadCount);
System.out.println(System.currentTimeMillis() - t);
}
}
@@ -228,8 +228,7 @@ public abstract class SharedTests
fail();
} catch (UnsupportedOperationException uoe) {} // expected
}
Map<String,String> partials = new LinkedHashMap<>();
@SafeVarargs
@@ -241,10 +240,10 @@ public abstract class SharedTests
partials = templates;
return name -> new StringReader(templates.get(name));
}
@Test public void testPartial () {
test(Mustache.compiler().withLoader(
partials(entry("foo", "inside:{{bar}}"),
partials(entry("foo", "inside:{{bar}}"),
entry("baz", "nonfoo")))
, "foo inside:foo nonfoo foo", "{{bar}} {{>foo}} {{>baz}} {{bar}}", context("bar", "foo"));
}
@@ -291,8 +290,8 @@ public abstract class SharedTests
@Test public void testNestedPartialIndent () {
Mustache.TemplateLoader loader = partials(entry("partial", "1\n {{>nest}}\n1\n"), entry("nest", "2\n{{{content}}}\n2\n"));
test(Mustache.compiler().withLoader(loader),
"|\n 1\n 2\n <\n->\n 2\n 1\n|\n",
test(Mustache.compiler().withLoader(loader),
"|\n 1\n 2\n <\n->\n 2\n 1\n|\n",
"|\n {{>partial}}\n|\n", context("content", "<\n->"));
}
@@ -848,13 +847,13 @@ public abstract class SharedTests
}
protected String name;
@Rule public TestRule watcher = new TestWatcher() {
protected void starting(Description description) {
name = description.getDisplayName();
}
};
protected void test(Mustache.Compiler compiler, String expected, String template, Object ctx) {
String actual = compiler.compile(template).execute(ctx);
if (! Objects.equals(expected, actual)) {
@@ -12,7 +12,7 @@ public class CustomSpecTest extends SpecTest {
public CustomSpecTest(Spec spec, String name) {
super(spec, name);
}
@Parameters(name = "{1}")
public static Collection<Object[]> data () {
String[] groups = new String[] {
@@ -20,5 +20,4 @@ public class CustomSpecTest extends SpecTest {
};
return SpecTest.data("/custom/specs/", groups);
}
}
@@ -25,5 +25,4 @@ public class OfficialSpecTest extends SpecTest {
};
return SpecTest.data("/specs/specs/", groups);
}
}
@@ -45,7 +45,7 @@ public class Spec
public String getPartial (String name) {
return partials == null ? null : partials.get(name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -61,4 +61,4 @@ public class Spec
value.accept(getExpectedOutput());
return sb.toString();
}
}
}
@@ -67,7 +67,6 @@ public abstract class SpecTest {
s = s.replace('\t', '\u21E5');
s = s.replace("\n", "\u21B5\n");
s = s.replace("\u240D", "\u240D\n");
return s;
}
@@ -75,7 +74,6 @@ public abstract class SpecTest {
return (text == null) ? null : text.replace("\r", "\\r").replace("\n", "\\n");
}
public static Collection<Object[]> data (String specPath, String[] groups) {
List<Object[]> tuples = new ArrayList<>();
int i = 0;
@@ -112,5 +110,4 @@ public abstract class SpecTest {
throw err;
}
}
}