Skip to content

Commit

Permalink
Move test case into SignatureTest. #48
Browse files Browse the repository at this point in the history
  • Loading branch information
uw4 committed Sep 18, 2024
1 parent 3849b71 commit abf12e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/test/java/com/dashjoin/jsonata/CustomFunctionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,4 @@ public Object call(Object input, @SuppressWarnings("rawtypes") List args) throws
Assertions.assertEquals("T0410", ex.getError());
Assertions.assertEquals("append", ex.getExpected());
}

@Disabled
@Test
public void testVarArg() {
var expression = Jsonata.jsonata("$sum(1,2,3)");
expression.registerFunction("sum", new JFunction(new JFunctionCallable() {
@SuppressWarnings("rawtypes")
@Override
public Object call(Object input, List args) throws Throwable {
int sum = 0;
for (Object i : args)
sum += (int) i;
return sum;
}
}, "<n+:n>"));
Assertions.assertEquals(6, expression.evaluate(null));
}
}
16 changes: 16 additions & 0 deletions src/test/java/com/dashjoin/jsonata/SignatureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ public Object call(Object input, @SuppressWarnings("rawtypes") List args) throws
// boolean not allowed
Assertions.assertThrows(JException.class, ()->expr.evaluate(true));
}

@Test
public void testVarArg() {
var expression = Jsonata.jsonata("$sumvar(1,2,3)");
expression.registerFunction("sumvar", new JFunction(new JFunctionCallable() {
@SuppressWarnings("rawtypes")
@Override
public Object call(Object input, List args) throws Throwable {
int sum = 0;
for (Object i : args)
sum += (int) i;
return sum;
}
}, "<n+:n>"));
Assertions.assertEquals(6, expression.evaluate(null));
}
}

0 comments on commit abf12e9

Please sign in to comment.