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 2023/03/02 14:38:21 UTC
[commons-jexl] branch master updated: JEXL: getting ready for 3.3;
This is an automated email from the ASF dual-hosted git repository.
henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
The following commit(s) were added to refs/heads/master by this push:
new 4c29b0a8 JEXL: getting ready for 3.3;
4c29b0a8 is described below
commit 4c29b0a8a497cfaa3c70fda6f4fdc2915945f456
Author: henrib <he...@apache.org>
AuthorDate: Thu Mar 2 15:38:15 2023 +0100
JEXL: getting ready for 3.3;
---
.../org/apache/commons/jexl3/Issues300Test.java | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
index 3976e889..3ec1d6b6 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -1253,6 +1253,27 @@ public class Issues300Test {
} catch(JexlException.Parsing xparse) {
Assert.assertTrue(xparse.getMessage().contains("total"));
}
+ }
+ @Test public void testDow() {
+ String src = "(y, m, d)->{\n" +
+ "// will return 0 for Sunday, 6 for Saturday\n" +
+ "const t = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4];\n"+
+ "if (m < 3) { --y }\n" +
+ "(y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;\n" +
+ "}";
+ JexlEngine jexl = new JexlBuilder()
+ .safe(false)
+ .strict(true)
+ .create();
+ JexlScript script = jexl.createScript(src);
+ Object r = script.execute(null, 2023, 3, 1);
+ Assert.assertTrue(r instanceof Number);
+ Number dow = (Number) r;
+ Assert.assertEquals(3, dow.intValue());
+ r = script.execute(null, 1969, 7, 20);
+ Assert.assertTrue(r instanceof Number);
+ dow = (Number) r;
+ Assert.assertEquals(0, dow.intValue());
}
}