freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [1/2] incubator-freemarker git commit: Forward ported from 2.3-gae: Additional interpolationSyntax tests
Date Sun, 18 Mar 2018 18:09:09 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 9a13687cc -> 782eed0b4


Forward ported from 2.3-gae: Additional interpolationSyntax 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/8093cb61
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/8093cb61
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/8093cb61

Branch: refs/heads/3
Commit: 8093cb612b0c17710f7cc6579c9704e629711b1b
Parents: 9a13687
Author: ddekany <ddekany@apache.org>
Authored: Sun Mar 18 18:47:44 2018 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Sun Mar 18 18:59:19 2018 +0100

----------------------------------------------------------------------
 .../core/InterpolationSyntaxTest.java           | 30 +++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/8093cb61/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpolationSyntaxTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpolationSyntaxTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpolationSyntaxTest.java
index 888b5a8..d187bb5 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpolationSyntaxTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpolationSyntaxTest.java
@@ -42,6 +42,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
@@ -60,9 +67,29 @@ public class InterpolationSyntaxTest extends TemplateTest {
         assertOutput("[ =1]", "[ =1]");
         
         assertErrorContains("<#if [true][0]]></#if>", "\"]\"", "nothing open");
+
+        setConfiguration(new TestConfigurationBuilder()
+                .tagSyntax(TagSyntax.SQUARE_BRACKET)
+                .interpolationSyntax(InterpolationSyntax.SQUARE_BRACKET)
+                .build());
+        assertOutput("[#if [true][0]]>[/#if]", ">");
+        assertOutput("[=1][=2]${3}", "12${3}");
+        setConfiguration(new TestConfigurationBuilder()
+                .tagSyntax(TagSyntax.ANGLE_BRACKET)
+                .interpolationSyntax(InterpolationSyntax.SQUARE_BRACKET)
+                .build());
         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");
+        
+        assertErrorContains("[=", "end of file");
+        assertErrorContains("[=1", "unclosed \"[\"");
         
         StringWriter sw = new StringWriter();
         new Template(null, "[= 1 + '[= 2 ]' ]", getConfiguration()).dump(sw);
@@ -79,6 +106,7 @@ public class InterpolationSyntaxTest extends TemplateTest {
                     .build());
             
             assertOutput("[#if [true][0]]t[#else]f[/#if]", "t");
+            assertOutput("[@r'[#if [true][0]]t[#else]f[/#if]'?interpret /]", "t");
         }
     }
     


Mime
View raw message