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 a62016e4dd34491306dba1940dc9524561d699be
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jun 1 18:49:57 2024 -0400

    Use assertThrows()
---
 src/test/java/org/apache/commons/jexl3/LexicalTest.java | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/LexicalTest.java 
b/src/test/java/org/apache/commons/jexl3/LexicalTest.java
index 978b20d2..88076620 100644
--- a/src/test/java/org/apache/commons/jexl3/LexicalTest.java
+++ b/src/test/java/org/apache/commons/jexl3/LexicalTest.java
@@ -779,7 +779,7 @@ public class LexicalTest {
         final JexlEngine jexl = new 
JexlBuilder().strict(true).lexical(true).create();
         final JexlContext ctxt = new DebugContext();
         Object result;
-        JexlScript script = jexl.createScript("var x = 42; var y = () -> { 
{var x = debug(-42); }; return x; }; y()");
+        final JexlScript script = jexl.createScript("var x = 42; var y = () -> 
{ {var x = debug(-42); }; return x; }; y()");
         result = script.execute(ctxt);
         assertEquals(42, result);
     }
@@ -812,7 +812,7 @@ public class LexicalTest {
         final JexlEngine jexl = new 
JexlBuilder().strict(true).lexical(true).lexicalShade(true).create();
         final JexlScript e = jexl.createScript(str);
         final JexlContext ctxt = new MapContext();
-        JexlException  xany = assertThrows(JexlException.class, () -> 
e.execute(ctxt), "i should be shaded");
+        final JexlException  xany = assertThrows(JexlException.class, () -> 
e.execute(ctxt), "i should be shaded");
         assertNotNull(xany.toString());
     }
 
@@ -832,7 +832,7 @@ public class LexicalTest {
         final JexlEngine jexl = new 
JexlBuilder().strict(true).lexical(true).lexicalShade(true).create();
         final JexlScript e = jexl.createScript(str);
         final JexlContext ctxt = new MapContext();
-        JexlException  xany = assertThrows(JexlException.class, () -> 
e.execute(ctxt), "i should be shaded");
+        final JexlException  xany = assertThrows(JexlException.class, () -> 
e.execute(ctxt), "i should be shaded");
         assertNotNull(xany.toString());
     }
 
@@ -942,7 +942,7 @@ public class LexicalTest {
         final JexlEngine jexl = new JexlBuilder().strict(false).create();
         final JexlScript e = jexl.createScript(str);
         final JexlContext ctxt = new MapContext();
-        JexlException  xany = assertThrows(JexlException.class, () -> 
e.execute(ctxt), "i should be shaded");
+        final JexlException  xany = assertThrows(JexlException.class, () -> 
e.execute(ctxt), "i should be shaded");
         assertNotNull(xany.toString());
     }
 
@@ -999,13 +999,7 @@ public class LexicalTest {
         f.lexical(true);
         f.lexicalShade(true);
         final JexlEngine jexl = createEngine(f);
-        try {
-            final JexlScript script = jexl.createScript("{var x = 0}; return 
x");
-            fail("Should not have been parsed");
-        } catch (final Exception ex) {
-           // OK
-           assertTrue(ex instanceof JexlException);
-        }
+        assertThrows(JexlException.class, () -> jexl.createScript("{var x = 
0}; return x"), "Should not have been parsed");
     }
 
     @Test

Reply via email to