You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2018/03/19 21:29:53 UTC
[07/12] incubator-freemarker git commit: Added some more
interpolation_syntax tests
Added some more interpolation_syntax tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/aeaafe51
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/aeaafe51
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/aeaafe51
Branch: refs/heads/2.3
Commit: aeaafe5132fdd8fdde773b29d3584921b2f81d8d
Parents: eb6781b
Author: ddekany <dd...@apache.org>
Authored: Fri Mar 16 18:48:51 2018 +0100
Committer: ddekany <dd...@apache.org>
Committed: Fri Mar 16 18:48:51 2018 +0100
----------------------------------------------------------------------
.../core/InterpolationSyntaxTest.java | 29 +++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/aeaafe51/src/test/java/freemarker/core/InterpolationSyntaxTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/InterpolationSyntaxTest.java b/src/test/java/freemarker/core/InterpolationSyntaxTest.java
index 3bd49be..c1721c8 100644
--- a/src/test/java/freemarker/core/InterpolationSyntaxTest.java
+++ b/src/test/java/freemarker/core/InterpolationSyntaxTest.java
@@ -16,6 +16,13 @@ public class InterpolationSyntaxTest extends TemplateTest {
assertOutput(
"${{'x': 1}['x']} #{{'x': 1}['x']} [={'x': 1}['x']]",
"1 1 [={'x': 1}['x']]");
+
+ assertOutput("${'a[=1]b'}", "a[=1]b");
+ assertOutput("${'a${1}#{2}b'}", "a12b");
+ assertOutput("${'a${1}#{2}b[=3]'}", "a12b[=3]");
+
+ assertOutput("<@r'${1} #{1} [=1]'?interpret />", "1 1 [=1]");
+ assertOutput("${'\"${1} #{1} [=1]\"'?eval}", "1 1 [=1]");
}
@Test
@@ -26,6 +33,13 @@ public class InterpolationSyntaxTest extends TemplateTest {
assertOutput(
"${{'x': 1}['x']} #{{'x': 1}['x']} [={'x': 1}['x']]",
"1 #{{'x': 1}['x']} [={'x': 1}['x']]");
+
+ assertOutput("${'a[=1]b'}", "a[=1]b");
+ assertOutput("${'a${1}#{2}b'}", "a1#{2}b");
+ assertOutput("${'a${1}#{2}b[=3]'}", "a1#{2}b[=3]");
+
+ assertOutput("<@r'${1} #{1} [=1]'?interpret />", "1 #{1} [=1]");
+ assertOutput("${'\"${1} #{1} [=1]\"'?eval}", "1 #{1} [=1]");
}
@Test
@@ -41,10 +55,22 @@ public class InterpolationSyntaxTest extends TemplateTest {
assertOutput("[= 1 ][= <#-- c --> 2 <#-- c --> ]", "12");
assertOutput("[ =1]", "[ =1]");
+ // Legacy tag closing glitch is not emulated with this:
assertErrorContains("<#if [true][0]]></#if>", "\"]\"", "nothing open");
+
+ getConfiguration().setTagSyntax(SQUARE_BRACKET_TAG_SYNTAX);
+ assertOutput("[#if [true][0]]>[/#if]", ">");
+ assertOutput("[=1][=2]${3}", "12${3}");
+ getConfiguration().setTagSyntax(ANGLE_BRACKET_TAG_SYNTAX);
assertOutput("[#ftl][#if [true][0]]>[/#if]", ">");
+ assertOutput("[#ftl][=1][=2]${3}", "12${3}");
assertOutput("[='a[=1]b']", "a1b");
+ assertOutput("[='a${1}#{2}b']", "a${1}#{2}b");
+ assertOutput("[='a${1}#{2}b[=3]']", "a${1}#{2}b3");
+
+ assertOutput("<@r'${1} #{1} [=1]'?interpret />", "${1} #{1} 1");
+ assertOutput("[='\"${1} #{1} [=1]\"'?eval]", "${1} #{1} 1");
}
@Test
@@ -53,6 +79,7 @@ public class InterpolationSyntaxTest extends TemplateTest {
for (int syntax : new int[] {
LEGACY_INTERPOLATION_SYNTAX, DOLLAR_INTERPOLATION_SYNTAX, SQUARE_BRACKET_INTERPOLATION_SYNTAX }) {
assertOutput("[#if [true][0]]t[#else]f[/#if]", "t");
+ assertOutput("[@r'[#if [true][0]]t[#else]f[/#if]'?interpret /]", "t");
}
}
@@ -65,7 +92,7 @@ public class InterpolationSyntaxTest extends TemplateTest {
assertOutput(ftl, "t");
}
- // Glitch is not emulated with this:
+ // Legacy tag closing glitch is not emulated with this:
getConfiguration().setInterpolationSyntax(SQUARE_BRACKET_INTERPOLATION_SYNTAX);
assertErrorContains(ftl, "\"]\"");
}