You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/06/01 20:04:34 UTC
(commons-jexl) 07/09: Use assertThrows()
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git
commit 54fed69a25b70a02ed9b81e5aac136bfe4758590
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 1 16:00:06 2024 -0400
Use assertThrows()
---
src/test/java/org/apache/commons/jexl3/Issues300Test.java | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/test/java/org/apache/commons/jexl3/Issues300Test.java b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
index 2c704aab..6dfeee4d 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -1077,12 +1077,14 @@ public class Issues300Test {
}
@Test public void testDow() {
+ // @formatter:off
final 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" +
"}";
+ // @formatter:on
final JexlEngine jexl = new JexlBuilder().create();
final JexlScript script = jexl.createScript(src);
Object r = script.execute(null, 2023, 3, 1);
@@ -1221,21 +1223,14 @@ public class Issues300Test {
@Test
public void tests301b() {
final JexlEngine jexl = new JexlBuilder().safe(false).arithmetic(new JexlArithmetic(false)).create();
- final Object[] xs = {null, null, new Object[]{null, 1}};
- final String[] srcs = {
- "x.0", "x[0]", "x[0][0]"
- };
+ final Object[] xs = { null, null, new Object[] { null, 1 } };
+ final String[] srcs = { "x.0", "x[0]", "x[0][0]" };
final JexlContext ctxt = new MapContext();
for (int i = 0; i < xs.length; ++i) {
ctxt.set("x", xs[i]);
final String src = srcs[i];
final JexlScript s = jexl.createScript(src);
- try {
- final Object o = s.execute(null);
- fail(src + ": Should have failed");
- } catch (final Exception ex) {
- //
- }
+ assertThrows(JexlException.class, () -> s.execute(null));
}
}