incubator-freemarker git commit: Added some more interpolation_syntax tests
Repository: incubator-freemarker Updated Branches: refs/heads/2.3-gae eb6781b44 -> aeaafe513 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-gae Commit: aeaafe5132fdd8fdde773b29d3584921b2f81d8d Parents: eb6781b Author: ddekany Authored: Fri Mar 16 18:48:51 2018 +0100 Committer: ddekany 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]]>", "\"]\"", "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, "\"]\""); }
[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 Authored: Fri Mar 16 18:48:51 2018 +0100 Committer: ddekany 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]]>", "\"]\"", "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, "\"]\""); }