You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by cb...@apache.org on 2019/02/26 16:20:10 UTC

svn commit: r1854404 - in /velocity/engine/trunk/velocity-engine-core/src: main/java/org/apache/velocity/runtime/parser/node/ASTNegateNode.java test/resources/templates/compare/math.cmp test/resources/templates/math.vm

Author: cbrisson
Date: Tue Feb 26 16:20:09 2019
New Revision: 1854404

URL: http://svn.apache.org/viewvc?rev=1854404&view=rev
Log:
[engine] Fix unary negate

Modified:
    velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNegateNode.java
    velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/math.cmp
    velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/math.vm

Modified: velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNegateNode.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNegateNode.java?rev=1854404&r1=1854403&r2=1854404&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNegateNode.java (original)
+++ velocity/engine/trunk/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTNegateNode.java Tue Feb 26 16:20:09 2019
@@ -57,7 +57,7 @@ public class ASTNegateNode extends Simpl
     public Object value( InternalContextAdapter context)
             throws MethodInvocationException
     {
-        Object value = jjtGetChild(0).evaluate( context );
+        Object value = jjtGetChild(0).value( context );
         try
         {
             value = DuckType.asNumber(value);

Modified: velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/math.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/math.cmp?rev=1854404&r1=1854403&r2=1854404&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/math.cmp (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/compare/math.cmp Tue Feb 26 16:20:09 2019
@@ -41,4 +41,7 @@ Test integer division
 
 Test decimal division
 5 / 2.0 = 2.5
-5.0 / 2 = 2.5
\ No newline at end of file
+5.0 / 2 = 2.5
+
+Unary negate
+-5 = -5 = -5 = -5 = -5 = -5

Modified: velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/math.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/math.vm?rev=1854404&r1=1854403&r2=1854404&view=diff
==============================================================================
--- velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/math.vm (original)
+++ velocity/engine/trunk/velocity-engine-core/src/test/resources/templates/math.vm Tue Feb 26 16:20:09 2019
@@ -59,4 +59,13 @@ Test integer division
 
 Test decimal division
 5 / 2.0 = #set($result = 5 / 2.0)$result
-5.0 / 2 = #set($result = 5.0 / 2)$result
\ No newline at end of file
+5.0 / 2 = #set($result = 5.0 / 2)$result
+
+Unary negate
+#set($five = 5)
+#set($a = 0 - $five)
+#set($b = 0-$five)
+#set($c = - $five)
+#set($d = -$five)
+#set($e =-$five)
+-5 = $a = $b = $c = $d = $e