Author: henrib
Date: Fri Aug 31 08:06:41 2012
New Revision: 1379348

URL: http://svn.apache.org/viewvc?rev=1379348&view=rev
Log:
Moved issue related test to ArithmeticTest;
Added question related test to VarTest;

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

Modified: 
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java?rev=1379348&r1=1379347&r2=1379348&view=diff
==============================================================================
--- 
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
 (original)
+++ 
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/ArithmeticTest.java
 Fri Aug 31 08:06:41 2012
@@ -356,4 +356,53 @@ public class ArithmeticTest extends Jexl
         result = script.execute(null);
         assertTrue((Boolean) result);
     }
-}
\ No newline at end of file
+
+    public static class EmptyTestContext extends MapContext implements 
JexlContext.NamespaceResolver {
+        public static int log(Object fmt, Object... arr) {
+            //System.out.println(String.format(fmt.toString(), arr));
+            return arr == null ? 0 : arr.length;
+        }
+
+        public static int log(Object fmt, int... arr) {
+            //System.out.println(String.format(fmt.toString(), arr));
+            return arr == null ? 0 : arr.length;
+        }
+
+        @Override
+        public Object resolveNamespace(String name) {
+            return this;
+        }
+    }
+
+    public void testEmpty() throws Exception {
+        Object[] SCRIPTS = {
+            "var x = null; log('x = %s', x);", 0,
+            "var x = 'abc'; log('x = %s', x);", 1,
+            "var x = 333; log('x = %s', x);", 1,
+            "var x = [1, 2]; log('x = %s', x);", 2,
+            "var x = ['a', 'b']; log('x = %s', x);", 2,
+            "var x = {1:'A', 2:'B'}; log('x = %s', x);", 1,
+            "var x = null; return empty(x);", true,
+            "var x = ''; return empty(x);", true,
+            "var x = 'abc'; return empty(x);", false,
+            "var x = 0; return empty(x);", true,
+            "var x = 333; return empty(x);", false,
+            "var x = []; return empty(x);", true,
+            "var x = [1, 2]; return empty(x);", false,
+            "var x = ['a', 'b']; return empty(x);", false,
+            "var x = {:}; return empty(x);", true,
+            "var x = {1:'A', 2:'B'}; return empty(x);", false
+        };
+        JexlEngine jexl = new JexlBuilder().create();
+        JexlContext jc = new EmptyTestContext();
+        JexlScript script;
+
+        for (int e = 0; e < SCRIPTS.length; e += 2) {
+            String stext = (String) SCRIPTS[e];
+            Object expected = SCRIPTS[e + 1];
+            script = jexl.createScript(stext);
+            Object result = script.execute(jc);
+            assertEquals("failed on " + stext, expected, result);
+        }
+    }
+}

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=1379348&r1=1379347&r2=1379348&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
 Fri Aug 31 08:06:41 2012
@@ -892,54 +892,4 @@ public class IssuesTest extends JexlTest
         result = expr.evaluate(jc);
         assertEquals("EXPR01 result", 22, result);
     }
-
-    public static class Context137 extends MapContext implements 
JexlContext.NamespaceResolver {
-        public static int log(Object fmt, Object... arr) {
-            //System.out.println(String.format(fmt.toString(), arr));
-            return arr == null ? 0 : arr.length;
-        }
-
-        public static int log(Object fmt, int... arr) {
-            //System.out.println(String.format(fmt.toString(), arr));
-            return arr == null ? 0 : arr.length;
-        }
-
-        @Override
-        public Object resolveNamespace(String name) {
-            return this;
-        }
-    }
-
-    @Test
-    public void test137() throws Exception {
-        Object[] SCRIPTS = {
-            "var x = null; log('x = %s', x);", 0,
-            "var x = 'abc'; log('x = %s', x);", 1,
-            "var x = 333; log('x = %s', x);", 1,
-            "var x = [1, 2]; log('x = %s', x);", 2,
-            "var x = ['a', 'b']; log('x = %s', x);", 2,
-            "var x = {1:'A', 2:'B'}; log('x = %s', x);", 1,
-            "var x = null; return empty(x);", true,
-            "var x = ''; return empty(x);", true,
-            "var x = 'abc'; return empty(x);", false,
-            "var x = 0; return empty(x);", true,
-            "var x = 333; return empty(x);", false,
-            "var x = []; return empty(x);", true,
-            "var x = [1, 2]; return empty(x);", false,
-            "var x = ['a', 'b']; return empty(x);", false,
-            "var x = {:}; return empty(x);", true,
-            "var x = {1:'A', 2:'B'}; return empty(x);", false
-        };
-        JexlEngine jexl = new JexlBuilder().create();
-        JexlContext jc = new Context137();
-        JexlScript script;
-
-        for (int e = 0; e < SCRIPTS.length; e += 2) {
-            String stext = (String) SCRIPTS[e];
-            Object expected = SCRIPTS[e + 1];
-            script = jexl.createScript(stext);
-            Object result = script.execute(jc);
-            assertEquals("failed on " + stext, expected, result);
-        }
-    }
 }

Modified: 
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java?rev=1379348&r1=1379347&r2=1379348&view=diff
==============================================================================
--- 
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java 
(original)
+++ 
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/VarTest.java 
Fri Aug 31 08:06:41 2012
@@ -253,6 +253,21 @@ public class VarTest extends JexlTestCas
         vars = e.getVariables();
         expect = mkref(new String[][]{{"A"}, {"B"}, {"C"}, {"D", "E", "F"}, 
{"x"} , {"y", "z"}});
         assertTrue(eq(expect, vars));
+
+        e = JEXL.createScript("(A)");
+        vars = e.getVariables();
+        expect = mkref(new String[][]{{"A"}});
+        assertTrue(eq(expect, vars));
+
+        e = JEXL.createScript("not(A)");
+        vars = e.getVariables();
+        expect = mkref(new String[][]{{"A"}});
+        assertTrue(eq(expect, vars));
+
+        e = JEXL.createScript("not((A))");
+        vars = e.getVariables();
+        expect = mkref(new String[][]{{"A"}});
+        assertTrue(eq(expect, vars));
     }
 
     public void testMix() throws Exception {


Reply via email to