You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2012/07/01 17:19:50 UTC

svn commit: r1355930 - in /commons/proper/jexl/branches/2.0/src: main/java/org/apache/commons/jexl2/JexlArithmetic.java test/java/org/apache/commons/jexl2/IssuesTest.java

Author: henrib
Date: Sun Jul  1 15:19:50 2012
New Revision: 1355930

URL: http://svn.apache.org/viewvc?rev=1355930&view=rev
Log:
Fix for JEXL-134 and associated test

Modified:
    commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
    commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl2/IssuesTest.java

Modified: commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java?rev=1355930&r1=1355929&r2=1355930&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java (original)
+++ commons/proper/jexl/branches/2.0/src/main/java/org/apache/commons/jexl2/JexlArithmetic.java Sun Jul  1 15:19:50 2012
@@ -1029,7 +1029,7 @@ public class JexlArithmetic {
             return new BigInteger(val.toString());
         } else if (val instanceof String) {
             String string = (String) val;
-            if ("".equals(string.trim())) {
+            if ("".equals(string)) {
                 return BigInteger.ZERO;
             } else {
                 return new BigInteger(string);
@@ -1059,7 +1059,7 @@ public class JexlArithmetic {
             controlNullOperand();
             return BigDecimal.ZERO;
         } else if (val instanceof String) {
-            String string = ((String) val).trim();
+            String string = (String) val;
             if ("".equals(string)) {
                 return BigDecimal.ZERO;
             }
@@ -1101,7 +1101,7 @@ public class JexlArithmetic {
         } else if (val instanceof Boolean) {
             return ((Boolean) val).booleanValue() ? 1. : 0.;
         } else if (val instanceof String) {
-            String string = ((String) val).trim();
+            String string = (String) val;
             if ("".equals(string)) {
                 return Double.NaN;
             } else {

Modified: commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl2/IssuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl2/IssuesTest.java?rev=1355930&r1=1355929&r2=1355930&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl2/IssuesTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/java/org/apache/commons/jexl2/IssuesTest.java Sun Jul  1 15:19:50 2012
@@ -24,6 +24,7 @@ import org.apache.commons.jexl2.internal
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.commons.jexl2.introspection.UberspectImpl;
+import org.junit.Test;
 
 /**
  * Test cases for reported issues
@@ -1051,4 +1052,17 @@ public class IssuesTest extends JexlTest
         Object evaluate = jexl.createExpression(expr).evaluate(null);
         assertEquals(42, evaluate);
     }
+
+    public void test134() throws Exception {
+        JexlEngine jexl = new JexlEngine();
+        String jexlExp = "$$__INPUT + nl";
+        Expression e = jexl.createExpression( jexlExp );
+        // Create a context and add data
+        JexlContext jc = new MapContext();
+        jc.set("$$__INPUT", "\r" );
+        jc.set("nl", "\n");
+        // Now evaluate the expression, getting the result
+        Object o = e.evaluate(jc);
+        assertEquals("\r\n", o);
+    }
 }