Author: nbubna
Date: Mon Feb 23 21:12:55 2009
New Revision: 747137

URL: http://svn.apache.org/viewvc?rev=747137&view=rev
Log:
tests for $<scope>.replaced

Modified:
    velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java

Modified: 
velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java?rev=747137&r1=747136&r2=747137&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java 
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/ScopeTestCase.java 
Mon Feb 23 21:12:55 2009
@@ -247,4 +247,52 @@
         assertEvalEquals("$foreach$foreach", "#foreach($i in 
[0..1])$foreach#end");
     }
 
+    public void testTemplateReplaced()
+    {
+        context.put("template", "foo");
+        addTemplate("test", "$template.replaced");
+        assertTmplEquals("foo", "test");
+        assertEvalEquals("foo", "#parse('test')");
+        assertContextValue("template", "foo");
+    }
+
+    public void testEvaluateReplaced()
+    {
+        context.put("evaluate","foo");
+        assertEvalEquals("foo", "$evaluate.replaced");
+        assertEvalEquals("foo", "#evaluate('$evaluate.replaced')");
+        assertContextValue("evaluate", "foo");
+    }
+
+    public void testMacroReplaced()
+    {
+        context.put("macro", "foo");
+        assertEvalEquals("foo foo foo", "$macro 
#macro(a)$macro.replaced#end#a() $macro");
+        assertContextValue("macro", "foo");
+    }
+
+    public void testForeachReplaced()
+    {
+        context.put("foreach", "foo");
+        assertEvalEquals("foofoofoo", "$foreach#foreach($i in 
[1..1])$foreach.replaced#end$foreach");
+        assertEquals("foo", context.get("foreach"));
+        context.put("foreach", "a");
+        assertEvalEquals("a", "#foreach($i in [1..1])#foreach($j in 
[1..1])$foreach.replaced#end#end");
+        assertContextValue("foreach", "a");
+    }
+
+    public void testDefineReplaced()
+    {
+        context.put("define", "a");
+        assertEvalEquals("a", "#define($a)$define.replaced#end$a");
+        assertContextValue("define", "a");
+    }
+
+    public void testBodyContentReplaced()
+    {
+        context.put("vm", "a");
+        assertEvalEquals("a", 
"#macro(vm)$bodycontent#e...@vm()$vm.replaced#end");
+        assertContextValue("vm", "a");
+    }
+
 }


Reply via email to