test interface default methods

This commit is contained in:
Robert Muir 2016-06-11 15:51:32 -04:00
parent c08b45a277
commit 454881eeb4
1 changed files with 9 additions and 0 deletions

View File

@ -119,6 +119,15 @@ public class FunctionRefTests extends ScriptTestCase {
"def l = new ArrayList(); l.add(2); l.add(1); l.sort(this::mycompare); return l.get(0);"));
}
public void testInterfaceDefaultMethod() {
assertEquals("bar", exec("String f(BiFunction function) { function.apply('foo', 'bar') }" +
"Map map = new HashMap(); f(map::getOrDefault)"));
}
public void testInterfaceDefaultMethodDef() {
assertEquals("bar", exec("String f(BiFunction function) { function.apply('foo', 'bar') }" +
"def map = new HashMap(); f(map::getOrDefault)"));
}
public void testMethodMissing() {
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {