From e588f2edf024a12ae5cb81c1d128b5791e56f117 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 4 Dec 2012 16:45:32 -0800 Subject: [PATCH] Clarify null-shadowing test a bit further with Object context version. --- .../com/samskivert/mustache/MustacheTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/samskivert/mustache/MustacheTest.java b/src/test/java/com/samskivert/mustache/MustacheTest.java index a6f755e..56d2230 100644 --- a/src/test/java/com/samskivert/mustache/MustacheTest.java +++ b/src/test/java/com/samskivert/mustache/MustacheTest.java @@ -357,10 +357,17 @@ public class MustacheTest } @Test public void testShadowedContextWithNull () { - test(Mustache.compiler().nullValue("(null)"), - "outer(null)", "{{foo}}{{#inner}}{{foo}}{{/inner}}", - context("foo", "outer", "inner", context("foo", null)) - ); + Mustache.Compiler comp = Mustache.compiler().nullValue("(null)"); + String tmpl = "{{foo}}{{#inner}}{{foo}}{{/inner}}", expect = "outer(null)"; + test(comp, expect, tmpl, new Object() { + public String foo = "outer"; + public Object inner = new Object() { + // this foo should shadow the outer foo even though it's null + public String foo = null; + }; + }); + // same as above, but with maps instead of objects + test(comp, expect, tmpl, context("foo", "outer", "inner", context("foo", null))); } @Test public void testFirst () {