abstract methods
This commit is contained in:
@@ -9,7 +9,6 @@ import java.util.List;
|
||||
public class ClassGenTest extends CodegenTestCase {
|
||||
public void testPSVMClass() throws Exception {
|
||||
loadFile("classes/simpleClass.jet");
|
||||
System.out.println(generateToText());
|
||||
|
||||
final Class aClass = loadClass("SimpleClass", generateClassesInFile());
|
||||
final Method[] methods = aClass.getDeclaredMethods();
|
||||
@@ -18,7 +17,6 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
|
||||
public void testArrayListInheritance() throws Exception {
|
||||
loadFile("classes/inheritingFromArrayList.jet");
|
||||
System.out.println(generateToText());
|
||||
|
||||
final Class aClass = loadClass("Foo", generateClassesInFile());
|
||||
checkInterface(aClass, List.class);
|
||||
@@ -66,4 +64,15 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
public void testInitializerBlock() throws Exception {
|
||||
blackBoxFile("classes/initializerBlock.jet");
|
||||
}
|
||||
|
||||
public void testAbstractMethod() throws Exception {
|
||||
loadText("class Foo { abstract fun x(): String; fun y(): Int = 0 }");
|
||||
|
||||
final Codegens codegens = generateClassesInFile();
|
||||
final Class aClass = loadClass("Foo", codegens);
|
||||
assertNotNull(aClass.getMethod("x"));
|
||||
final Class implClass = loadClass("Foo$$Impl", codegens);
|
||||
assertNull(findMethodByName(implClass, "x"));
|
||||
assertNotNull(findMethodByName(implClass, "y"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
@Nullable
|
||||
protected static Method findMethodByName(Class aClass, String name) {
|
||||
for (Method method : aClass.getMethods()) {
|
||||
for (Method method : aClass.getDeclaredMethods()) {
|
||||
if (method.getName().equals(name)) {
|
||||
return method;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,8 @@ public class PropertyGenTest extends CodegenTestCase {
|
||||
final Object instance = aClass.newInstance();
|
||||
final Method getFoo = findMethodByName(aClass, "getFoo");
|
||||
assertEquals(349, getFoo.invoke(instance));
|
||||
assertNull(findMethodByName(aClass, "setFoo"));
|
||||
final Method setFoo = findMethodByName(aClass, "setFoo");
|
||||
assertTrue((setFoo.getModifiers() & Modifier.PRIVATE) != 0);
|
||||
final Method setter = findMethodByName(aClass, "setter");
|
||||
setter.invoke(instance);
|
||||
assertEquals(610, getFoo.invoke(instance));
|
||||
|
||||
Reference in New Issue
Block a user