commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r589309 - /commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java
Date Sun, 28 Oct 2007 09:06:18 GMT
Author: dion
Date: Sun Oct 28 02:06:16 2007
New Revision: 589309

URL: http://svn.apache.org/viewvc?rev=589309&view=rev
Log:
Add tests for JEXL-26
Add tests for method calls on array objects:
- get(index), set(index,Object), size()

Modified:
    commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java

Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java?rev=589309&r1=589308&r2=589309&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java
(original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/ArrayAccessTest.java
Sun Oct 28 02:06:16 2007
@@ -122,5 +122,27 @@
         asserter.assertExpression("foo.array2[1][1]", GET_METHOD_ARRAY2[1][1]);
         // asserter.assertExpression("foo.array2.1.1", GET_METHOD_ARRAY2[1][1]);
     }
+    
+    // This is JEXL-26
+    public void testArrayAndDottedConflict() throws Exception {
+        Object[] objects = new Object[] {"an", "array", new Long(0)};
+        
+        asserter.setVariable("objects", objects);
+        asserter.setVariable("status", "Enabled");
+        asserter.assertExpression("objects[1].status", null);
+        
+        asserter.setVariable("base.status", "Ok");
+        asserter.assertExpression("base.objects[1].status", null);
+    }
 
+    public void testArrayMethods() throws Exception {
+        Object[] objects = new Object[] {"an", "array", new Long(0)};
+        
+        asserter.setVariable("objects", objects);
+        asserter.assertExpression("objects.get(1)", "array");
+        asserter.assertExpression("objects.size()", new Integer(3));
+        // setting an index returns the old value
+        asserter.assertExpression("objects.set(1, 'dion')", "array");
+        asserter.assertExpression("objects[1]", "dion");
+    }
 }



Mime
View raw message