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 2ebc59939999e591a171f3ed37f8ce1e4569b4f7
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 1 15:57:51 2024 -0400

    Use assertThrows()
---
 .../java/org/apache/commons/jexl3/Issues300Test.java   | 18 ++++++++----------
 1 file changed, 8 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 68b58699..3e94c655 100644
--- a/src/test/java/org/apache/commons/jexl3/Issues300Test.java
+++ b/src/test/java/org/apache/commons/jexl3/Issues300Test.java
@@ -1024,22 +1024,20 @@ public class Issues300Test {
 
     @Test
     public void test390() throws Exception {
+        // @formatter:off
         final JexlEngine jexl = new JexlBuilder()
                 .safe(false)
                 .strict(true)
                 .debug(true)
                 .create();
+        // @formatter:on
         JexlScript script = null;
-        String src;
-        src = "if (true) #pragma one 42";
-        try {
-            script = jexl.createScript(src);
-            fail("should have failed parsing");
-        } catch (final JexlException.Parsing xparse) {
-            assertTrue(xparse.getDetail().contains("pragma"));
-        }
-        src = "if (true) { #pragma one 42 }";
-        script = jexl.createScript(src);
+        final String src = "if (true) #pragma one 42";
+        final JexlException.Parsing xparse = 
assertThrows(JexlException.Parsing.class, () -> jexl.createScript(src), "should 
have failed parsing");
+        assertTrue(xparse.getDetail().contains("pragma"));
+
+        String src1 = "if (true) { #pragma one 42 }";
+        script = jexl.createScript(src1);
         final Object result = script.execute(null);
         debuggerCheck(jexl);
     }

Reply via email to