jstrachan 2002/12/16 02:42:26 Modified: jexl/src/test/org/apache/commons/jexl JexlTest.java Log: Added another failing unit test case. The parser cannot handle foo.count != -1 Revision Changes Path 1.25 +26 -15 jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl/JexlTest.java Index: JexlTest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl/JexlTest.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JexlTest.java 20 Nov 2002 12:58:39 -0000 1.24 +++ JexlTest.java 16 Dec 2002 10:42:26 -0000 1.25 @@ -53,21 +53,17 @@ */ package org.apache.commons.jexl; -import junit.framework.TestCase; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.apache.commons.jexl.parser.Parser; -import org.apache.commons.jexl.parser.SimpleNode; -import org.apache.commons.jexl.Expression; -import org.apache.commons.jexl.ExpressionFactory; -import org.apache.commons.jexl.resolver.FlatResolver; - -import java.io.StringReader; import java.util.ArrayList; -import java.util.List; import java.util.HashMap; +import java.util.List; import java.util.Map; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.commons.jexl.resolver.FlatResolver; + /** * Simple testcases * @@ -825,15 +821,30 @@ // lets check the square function first.. assertEquals(4, foo.square(2)); assertEquals(4, foo.square(-2)); - + jc.getVars().put("foo", foo ); Object o = e.evaluate(jc); assertEquals("o incorrect", new Integer(5), o); - + assertExpression(jc, "foo.square(2)", new Integer(4)); assertExpression(jc, "foo.square(-2)", new Integer(4)); - } + } + + /** + * test the -1 comparison bug + */ + public void testNegativeIntComparison() + throws Exception + { + JexlContext jc = JexlHelper.createContext(); + Foo foo = new Foo(); + jc.getVars().put("foo", foo ); + + assertExpression(jc, "foo.count != -1", Boolean.TRUE); + assertExpression(jc, "foo.count == 5", Boolean.TRUE); + assertExpression(jc, "foo.count == -1", Boolean.FALSE); + } public void testArrayProperty() throws Exception
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>