Fix compiling of functions with single character arguments
@ -195,7 +195,7 @@ public class PathCompiler {
}
else if (c == OPEN_PARENTHESIS) {
isFunction = true;
endPosition = readPosition++;
endPosition = readPosition;
break;
readPosition++;
@ -296,6 +296,14 @@ public class PathCompilerTest {
assertThat(result).containsExactly("] it");
@Test
public void a_function_can_be_compiled() {
assertThat(compile("$.aaa.foo()").toString()).isEqualTo("$['aaa'].foo()");
assertThat(compile("$.aaa.foo(5)").toString()).isEqualTo("$['aaa'].foo(...)");
assertThat(compile("$.aaa.foo($.bar)").toString()).isEqualTo("$['aaa'].foo(...)");
assertThat(compile("$.aaa.foo(5,10,15)").toString()).isEqualTo("$['aaa'].foo(...)");
@Test(expected = InvalidPathException.class)
public void array_indexes_must_be_separated_by_commas() {
compile("$[0, 1, 2 4]");
@ -58,6 +58,12 @@ public class NestedFunctionTest extends BaseFunctionTest {
verifyMathFunction(conf, "$.sum(5, 3, $.numbers.max(), 2)", 20.0);
public void testSimpleLiteralArgument() {
verifyMathFunction(conf, "$.sum(5)", 5.0);
verifyMathFunction(conf, "$.sum(50)", 50.0);
public void testStringConcat() {
verifyTextFunction(conf, "$.text.concat()", "abcdef");