Call 'invokeBox' with proper class instance (not try to find it via reflection)

This commit is contained in:
Michael Bogdanov
2016-04-26 12:02:42 +03:00
parent 1eb3d2ec1d
commit 11e42c6472
3 changed files with 15 additions and 14 deletions
@@ -22,11 +22,8 @@ import java.lang.reflect.Method;
public class AbstractCodegenTestCaseOnAndroid extends TestCase {
protected void invokeBoxMethod(String filePath, String expectedResult) throws Exception {
protected void invokeBoxMethod(Class clazz, String filePath, String expectedResult) throws Exception {
try {
String simpelName = filePath.substring(filePath.lastIndexOf("/") + 1);
String packageName = filePath.replaceAll("\\\\|-|\\.|/", "_");
Class clazz = Class.forName(packageName + "." + getPackageClassName(simpelName));
Method method = clazz.getMethod("box");
assertEquals(expectedResult, method.invoke(null));
}
@@ -34,8 +31,4 @@ public class AbstractCodegenTestCaseOnAndroid extends TestCase {
throw new RuntimeException("File: " + filePath, e);
}
}
public static String getPackageClassName(String fileName) {
return Character.toUpperCase(fileName.charAt(0)) + fileName.substring(1).replaceAll("\\.kt", "Kt");
}
}