add a few more tests

This commit is contained in:
Robert Muir 2016-06-20 10:46:23 -04:00
parent 9111ed3e2c
commit 9510a8f39e
1 changed files with 13 additions and 0 deletions

View File

@ -161,6 +161,11 @@ public class LambdaTests extends ScriptTestCase {
"return Optional.empty().orElseGet(() -> x ? 5 : Optional.empty().orElseGet(() -> y));"));
}
public void testNestedCaptureParams() {
assertEquals(2, exec("int foo(Function f) { return f.apply(1) }" +
"return foo(x -> foo(y -> x + 1))"));
}
public void testWrongArity() {
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("Optional.empty().orElseGet(x -> x);");
@ -174,4 +179,12 @@ public class LambdaTests extends ScriptTestCase {
});
assertTrue(expected.getMessage(), expected.getMessage().contains("Incorrect number of parameters"));
}
public void testLambdaInFunction() {
assertEquals(5, exec("def foo() { Optional.empty().orElseGet(() -> 5) } return foo();"));
}
public void testLambdaCaptureFunctionParam() {
assertEquals(5, exec("def foo(int x) { Optional.empty().orElseGet(() -> x) } return foo(5);"));
}
}