@@ -577,7 +577,7 @@ public void test274() throws Exception {
577
577
JexlEngine jexl = new JexlBuilder ().strict (true ).safe (true ).stackOverflow (5 ).create ();
578
578
final JexlContext ctxt = new MapContext ();
579
579
final JexlScript script = jexl .createScript ("var f = (x)->{ x > 1? x * f(x - 1) : x }; f(a)" , "a" );
580
- Object result = script .execute (ctxt , 3 );
580
+ final Object result = script .execute (ctxt , 3 );
581
581
assertEquals (6 , result );
582
582
JexlException .StackOverflow xstack = assertThrows (JexlException .StackOverflow .class , () -> script .execute (ctxt , 32 ));
583
583
assertTrue (xstack .toString ().contains ("jexl" ));
@@ -655,7 +655,7 @@ public void test278() throws Exception {
655
655
final JexlException .Ambiguous xa = assertThrows (JexlException .Ambiguous .class , () -> jexl .createScript (src ));
656
656
final String str = xa .toString ();
657
657
assertTrue (str .contains ("143" ));
658
- String clean = xa .tryCleanSource (src );
658
+ final String clean = xa .tryCleanSource (src );
659
659
660
660
jc = jexl .createScript (clean );
661
661
value = jc .execute (ctxt );
@@ -845,24 +845,16 @@ public void test287() {
845
845
// definition using shadowed global
846
846
options .setLexical (false );
847
847
src = "(x)->{ if (x==1) { var y = 2; } else if (x==2) { var y = 3; }; y }" ;
848
- script = jexl .createScript (src );
849
- result = script .execute (ctxt , 1 );
848
+ final JexlScript script1 = jexl .createScript (src );
849
+ result = script1 .execute (ctxt , 1 );
850
850
assertEquals (2 , result );
851
- result = script .execute (ctxt , 2 );
851
+ result = script1 .execute (ctxt , 2 );
852
852
assertEquals (3 , result );
853
853
options .setStrict (true );
854
- try {
855
- result = script .execute (ctxt , 0 );
856
- fail ("should have failed!" );
857
- } catch (final JexlException .Variable xvar ) {
858
- assertTrue (xvar .getMessage ().contains ("y" ));
859
- }
854
+ final JexlException .Variable xvar = assertThrows (JexlException .Variable .class , () -> script1 .execute (ctxt , 0 ));
855
+ assertTrue (xvar .getMessage ().contains ("y" ));
860
856
options .setStrict (false );
861
- try {
862
- result = script .execute (ctxt , 0 );
863
- } catch (final JexlException xvar ) {
864
- fail ("should not have failed!" );
865
- }
857
+ result = script1 .execute (ctxt , 0 );
866
858
assertNull (result );
867
859
}
868
860
0 commit comments