From 5dd87e2769b93a9146217f7ff7042be69889141d Mon Sep 17 00:00:00 2001 From: emcmanus Date: Mon, 22 Jan 2018 17:04:06 -0800 Subject: Make reference handling in odd cases more similar to Velocity. If you have `${` not followed by an identifier (so not `${foo.bar}` or whatever) then those are just two plain-text characters. If you have `$foo.!` rather than `$foo.bar` then the `.!` are just plain-text characters. RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182860539 --- .../auto/value/processor/escapevelocity/TemplateTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'value/src/test/java/com/google') diff --git a/value/src/test/java/com/google/auto/value/processor/escapevelocity/TemplateTest.java b/value/src/test/java/com/google/auto/value/processor/escapevelocity/TemplateTest.java index 16b06b83..32bd0103 100644 --- a/value/src/test/java/com/google/auto/value/processor/escapevelocity/TemplateTest.java +++ b/value/src/test/java/com/google/auto/value/processor/escapevelocity/TemplateTest.java @@ -203,6 +203,11 @@ public class TemplateTest { compare("=${t.name}=", ImmutableMap.of("t", Thread.currentThread())); } + @Test + public void substituteNotPropertyId() { + compare("$foo.!", ImmutableMap.of("foo", false)); + } + /* TODO(emcmanus): make this work. @Test public void substituteNotPropertyId() { @@ -698,6 +703,14 @@ public class TemplateTest { compare(template); } + @Test + public void badBraceReference() throws IOException { + String template = "line 1\nline 2\nbar${foo.!}baz"; + thrown.expect(ParseException.class); + thrown.expectMessage("Expected }, on line 3, at text starting: .!}baz"); + Template.parseFrom(new StringReader(template)); + } + @Test public void undefinedMacro() throws IOException { String template = "#oops()"; -- cgit v1.2.3