blob: fb803d1661017ea2b3d5323f2fbd8f1acd0d17ee [file] [log] [blame]
class InterfaceConversionTest extends GroovyTestCase {
void testClosureConversion(){
def c1 = {Object[] args -> args?.length}
def c2 = c1 as InterfaceConversionTestFoo
assert !(c1 instanceof InterfaceConversionTestFoo)
assert c2 instanceof InterfaceConversionTestFoo
assert c2.a() == null
assert c2.b(null) == 1
}
void testMapConversion() {
def m1 = [a:{1}, b:{2}]
def m2 = m1 as InterfaceConversionTestFoo
assert !(m1 instanceof InterfaceConversionTestFoo)
assert m2 instanceof InterfaceConversionTestFoo
assert m2.a() == 1
assert m2.b(null) == 2
}
}
interface InterfaceConversionTestFoo {
def a();
def b(Integer i);
}