commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject svn commit: r1357520 - /commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java
Date Thu, 05 Jul 2012 09:27:33 GMT
Author: henrib
Date: Thu Jul  5 09:27:32 2012
New Revision: 1357520

URL: http://svn.apache.org/viewvc?rev=1357520&view=rev
Log:
Test for JEXL-135;

Modified:
    commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java

Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java?rev=1357520&r1=1357519&r2=1357520&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IssuesTest.java Thu Jul
 5 09:27:32 2012
@@ -830,15 +830,47 @@ public class IssuesTest extends JexlTest
 
     public void test135() throws Exception {
         JexlEngine jexl = new Engine();
+        JexlContext jc = new MapContext();
         JexlScript script;
         Object result;
         Map<Integer, Object> foo = new HashMap<Integer, Object>();
         foo.put(3, 42);
+        jc.set("state", foo);
+
+        script = jexl.createScript("var y = state[3]; y");
+        result = script.execute(jc, foo);
+        assertEquals(42, result);
+
+        jc.set("a", 3);
+        script = jexl.createScript("var y = state[a]; y");
+        result = script.execute(jc, foo);
+        assertEquals(42, result);
+
+        jc.set("a", 2);
+        script = jexl.createScript("var y = state[a + 1]; y");
+        result = script.execute(jc, foo);
+        assertEquals(42, result);
+
+        jc.set("a", 2);
+        jc.set("b", 1);
+        script = jexl.createScript("var y = state[a + b]; y");
+        result = script.execute(jc, foo);
+        assertEquals(42, result);
+
         script = jexl.createScript("var y = state[3]; y", "state");
-        result = script.execute(null, foo);
+        result = script.execute(null, foo, 3);
+        assertEquals(42, result);
+
+        script = jexl.createScript("var y = state[a]; y", "state", "a");
+        result = script.execute(null, foo, 3);
         assertEquals(42, result);
-        script = jexl.createScript("var y = state[1 + 1 + 1]; y", "state");
-        result = script.execute(null, foo);
+
+        script = jexl.createScript("var y = state[a + 1]; y", "state", "a");
+        result = script.execute(null, foo, 2);
+        assertEquals(42, result);
+
+        script = jexl.createScript("var y = state[a + b]; y", "state", "a", "b");
+        result = script.execute(null, foo, 2, 1);
         assertEquals(42, result);
     }
 }



Mime
View raw message