From ca08cdb1a4aa570daa2cea54cd09663cb5bc6fb5 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 4 Feb 2021 13:20:00 -0800 Subject: [PATCH] Tests for some first/last stuff. From @spacether. --- .../com/samskivert/mustache/SharedTests.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/com/samskivert/mustache/SharedTests.java b/src/test/java/com/samskivert/mustache/SharedTests.java index 4445a3c..33f1b17 100644 --- a/src/test/java/com/samskivert/mustache/SharedTests.java +++ b/src/test/java/com/samskivert/mustache/SharedTests.java @@ -473,6 +473,26 @@ public abstract class SharedTests extends GWTTestCase context("things", Arrays.asList("foo"))); } + @Test public void testFirstLastCombo () { + test("FIRST_and_LAST", "{{#things}}{{#-first}}FIRST{{/-first}}{{this}}{{#-last}}LAST{{/-last}}{{/things}}", + context("things", Arrays.asList("_and_"))); + } + + @Test public void testInverseFirstLastCombo () { + test("_and_", "{{#things}}{{^-first}}NOT-FIRST{{/-first}}{{this}}{{^-last}}NOT-LAST{{/-last}}{{/things}}", + context("things", Arrays.asList("_and_"))); + } + + @Test public void testNotFirst () { + test("1,2,3", "{{#things}}{{^-first}},{{/-first}}{{this}}{{/things}}", + context("things", Arrays.asList("1", "2", "3"))); + } + + @Test public void testNotLast () { + test("1,2,3", "{{#things}}{{this}}{{^-last}},{{/-last}}{{/things}}", + context("things", Arrays.asList("1", "2", "3"))); + } + @Test public void testIndex () { test("123", "{{#things}}{{-index}}{{/things}}", context("things", Arrays.asList("foo", "bar", "baz")));