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 2017/07/05 10:17:55 UTC
svn commit: r1800855 -
/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java
Author: henrib
Date: Wed Jul 5 10:17:55 2017
New Revision: 1800855
URL: http://svn.apache.org/viewvc?rev=1800855&view=rev
Log:
JEXL: added null coalescing operator script test
Modified:
commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java
Modified: commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java?rev=1800855&r1=1800854&r2=1800855&view=diff
==============================================================================
--- commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java (original)
+++ commons/proper/jexl/trunk/src/test/java/org/apache/commons/jexl3/IfTest.java Wed Jul 5 10:17:55 2017
@@ -367,4 +367,23 @@ public class IfTest extends JexlTestCase
Assert.assertEquals("Should be 0", 0, o);
debuggerCheck(JEXL);
}
+
+ @Test
+ public void testNullCoaelescingScript() throws Exception {
+ Object o;
+ JexlEvalContext jc = new JexlEvalContext();
+ JexlScript xtrue = JEXL.createScript("x??true");
+ o = xtrue.execute(jc);
+ Assert.assertEquals("Should be true", true, o);
+ jc.set("x", false);
+ o = xtrue.execute(jc);
+ Assert.assertEquals("Should be false", false, o);
+ JexlScript yone = JEXL.createScript("y??1");
+ o = yone.execute(jc);
+ Assert.assertEquals("Should be 1", 1, o);
+ jc.set("y", 0);
+ o = yone.execute(jc);
+ Assert.assertEquals("Should be 0", 0, o);
+ debuggerCheck(JEXL);
+ }
}