зеркало из https://github.com/mozilla/pluotsorbet.git
Merge pull request #1207 from marco-c/test_class_forname_in_static
Test calling Class.forName in a static initializer
This commit is contained in:
Коммит
97c641cb04
|
@ -0,0 +1,28 @@
|
|||
package gnu.testlet.vm;
|
||||
|
||||
import gnu.testlet.TestHarness;
|
||||
import gnu.testlet.Testlet;
|
||||
|
||||
public class ClassForNameInStaticInitializerTest implements Testlet {
|
||||
public int getExpectedPass() { return 2; }
|
||||
public int getExpectedFail() { return 0; }
|
||||
public int getExpectedKnownFail() { return 0; }
|
||||
|
||||
private static boolean test1 = ClassForNameInStaticInitializerTest.canLoad("java.lang.Object");
|
||||
private static boolean test2 = ClassForNameInStaticInitializerTest.canLoad("java.lang.DoesntExist");
|
||||
|
||||
public static boolean canLoad(String className) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void test(TestHarness th) {
|
||||
th.check(test1, "java.lang.Object exists");
|
||||
th.check(!test2, "java.lang.DoesntExist doesn't exist");
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче