camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1401209 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/language/simple/SimpleExpressionParser.java test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
Date Tue, 23 Oct 2012 09:04:25 GMT
Author: davsclaus
Date: Tue Oct 23 09:04:25 2012
New Revision: 1401209

URL: http://svn.apache.org/viewvc?rev=1401209&view=rev
Log:
CAMEL-5736: Simple language - Unary operators should be more lenient and only be applicable
if previous node is a function expression

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java?rev=1401209&r1=1401208&r2=1401209&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleExpressionParser.java
Tue Oct 23 09:04:25 2012
@@ -147,7 +147,10 @@ public class SimpleExpressionParser exte
             functions.decrementAndGet();
             return new SimpleFunctionEnd(token);
         } else if (token.getType().isUnary()) {
-            return new UnaryExpression(token);
+            // there must be a end function as previous, to let this be a unary function
+            if (!nodes.isEmpty() && nodes.get(nodes.size() - 1) instanceof SimpleFunctionEnd)
{
+                return new UnaryExpression(token);
+            }
         }
 
         // by returning null, we will let the parser determine what to do

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java?rev=1401209&r1=1401208&r2=1401209&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/simple/SimpleOperatorTest.java
Tue Oct 23 09:04:25 2012
@@ -458,6 +458,24 @@ public class SimpleOperatorTest extends 
         }
     }
 
+    public void testUnaryInc() throws Exception {
+        assertExpression("${in.header.bar}++", 124);
+        assertExpression("+++++++++++++", "+++++++++++++");
+        assertExpression("Logging ++ start ++", "Logging ++ start ++");
+        assertExpression("Logging +++ start +++", "Logging +++ start +++");
+        assertExpression("++ start ++", "++ start ++");
+        assertExpression("+++ start +++", "+++ start +++");
+    }
+
+    public void testUnaryDec() throws Exception {
+        assertExpression("${in.header.bar}--", 122);
+        assertExpression("-------------", "-------------");
+        assertExpression("Logging -- start --", "Logging -- start --");
+        assertExpression("Logging --- start ---", "Logging --- start ---");
+        assertExpression("-- start --", "-- start --");
+        assertExpression("--- start ---", "--- start ---");
+    }
+
     protected String getLanguageName() {
         return "simple";
     }



Mime
View raw message