Skip to content

Commit

Permalink
JEXL-425, JEXL-426, JEXL-427 : checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
henrib committed Aug 27, 2024
1 parent ba11d0e commit 3662b16
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 15 deletions.
8 changes: 0 additions & 8 deletions src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
Original file line number Diff line number Diff line change
Expand Up @@ -2070,14 +2070,6 @@ public BigInteger toBigInteger(final Object val) {
+ val.getClass().getName() + ":(" + val + ")");
}

public Object falsy(Object arg) {
return false;
}

public Object truthy(Object arg) {
return true;
}

/**
* Coerce to a primitive boolean.
* <p>Double.NaN, null, "false" and empty string coerce to false.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.commons.jexl3.parser;

public final class ASTAmbiguous extends JexlNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class ASTJexlScript extends JexlLexicalNode {
/** The pragmas. */
private Map<String, Object> pragmas;
/** Features. */
private transient JexlFeatures features = null;
private transient JexlFeatures features;
/** The script scope. */
private transient Scope scope = null;
private transient Scope scope;

public ASTJexlScript(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class ASTJxltLiteral extends JexlNode implements JexlNode.JxltHandl
/** The actual literal value. */
private String literal;
/** The expression (parsed). */
private transient JxltEngine.Expression jxltExpression = null;
private transient JxltEngine.Expression jxltExpression;

ASTJxltLiteral(final int id) {
super(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface JxltHandle {
* <p>Used to parse expressions for templates.
*/
public static class Info extends JexlInfo {
JexlNode node = null;
JexlNode node;

/**
* Default ctor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ protected static String addEscapes(final String str) {
private int column;

/** Full Constructor. */
public TokenMgrException(final boolean EOFSeen, final int lexState, final int errorLine, final int errorColumn, final String errorAfter, final int curChar, final int reason) {
public TokenMgrException(final boolean EOFSeen, final int lexState, final int errorLine, final int errorColumn,
final String errorAfter, final int curChar, final int reason) {
eof = EOFSeen;
state = lexState;
line = errorLine;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/apache/commons/jexl3/FeaturesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.commons.jexl3;

import static org.apache.commons.jexl3.JexlFeatures.CONST_CAPTURE;
import static org.apache.commons.jexl3.JexlFeatures.REF_CAPTURE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down
42 changes: 41 additions & 1 deletion src/test/java/org/apache/commons/jexl3/Issues400Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public void testSortArray() {
assertEquals("42", result);
}

@Test public void test426() {
@Test public void test426a() {
String src = "let x = 10;\n" +
"let foo = () -> {\n" +
"x += 2;\n" +
Expand All @@ -510,6 +510,46 @@ public void testSortArray() {
assertEquals(42, result);
}

@Test public void test426b() {
String src = "let x = 10; let f = () -> { x + 2 }; x = 40; f()";
final JexlBuilder builder = new JexlBuilder().features(new JexlFeatures().constCapture(true).referenceCapture(true));
final JexlEngine jexl = builder.create();
JexlScript script;
Object result;
script = jexl.createScript(src);
result = script.execute(null);
assertEquals(42, result);
}

@Test public void test426c() {
String src = "let x = 10; let f = () -> { x + 2 }; x = 40; f";
final JexlBuilder builder = new JexlBuilder().features(new JexlFeatures().constCapture(true).referenceCapture(true));
final JexlEngine jexl = builder.create();
JexlScript script;
Object result;
script = jexl.createScript(src);
result = script.execute(null);
assertTrue(result instanceof JexlScript);
script = jexl.createScript("f()", "f");
result = script.execute(null, result);
assertEquals(42, result);
}

@Test public void test426d() {
String src = "let x = 10; let f = () -> { let x = 142; x }; x = 40; f";
final JexlBuilder builder = new JexlBuilder().features(new JexlFeatures().referenceCapture(true));
final JexlEngine jexl = builder.create();
JexlScript script;
Object result;
script = jexl.createScript(src);
result = script.execute(null);
assertTrue(result instanceof JexlScript);
script = jexl.createScript("f()", "f");
result = script.execute(null, result);
assertEquals(142, result);
}


@Test public void test427a() {
String src = "(x, y, z) -> x && y && z";
final JexlBuilder builder = new JexlBuilder().features(new JexlFeatures().constCapture(true));
Expand Down

0 comments on commit 3662b16

Please sign in to comment.