Fix bugs in metaprogramming. In JUnit runner reload about:blank page before every test

This commit is contained in:
Alexey Andreev 2017-02-13 23:43:49 +03:00
parent edb3d2ff48
commit ccb4dff836
4 changed files with 12 additions and 8 deletions

View File

@ -80,7 +80,8 @@ public final class Metaprogramming {
}
public static <T> Value<T> proxy(Class<T> type, InvocationHandler<T> handler) {
return proxy(findClass(type), handler);
unsupported();
return null;
}
public static <T> Value<T> proxy(ReflectClass<T> type, InvocationHandler<T> handler) {

View File

@ -176,11 +176,11 @@ public final class MetaprogrammingImpl {
}
public static void location(String fileName, int lineNumber) {
unsupported();
generator.forcedLocation = new TextLocation(fileName, lineNumber);
}
public static void defaultLocation() {
unsupported();
generator.forcedLocation = null;
}
@SuppressWarnings("WeakerAccess")
@ -249,6 +249,7 @@ public final class MetaprogrammingImpl {
returnType = methodHolder.getResultType();
varContext = nestedVarContext;
generator = new CompositeMethodGenerator(varContext, new Program());
generator.forcedLocation = generatorBackup.forcedLocation;
Program program = generator.program;
program.createBasicBlock();

View File

@ -26,6 +26,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>teavm-junit</artifactId>
<name>TeaVM JUnit runner</name>
<description>TeaVM implementation of JUnit API</description>
<dependencies>
<dependency>

View File

@ -52,6 +52,11 @@ class HtmlUnitRunStrategy implements TestRunStrategy {
init();
}
try {
page.set(webClient.get().getPage("about:blank"));
} catch (IOException e) {
throw new RuntimeException(e);
}
page.get().executeJavaScript(readFile(new File(run.getBaseDirectory(), "runtime.js")));
page.get().executeJavaScript(readFile(new File(run.getBaseDirectory(), "test.js")));
@ -75,11 +80,6 @@ class HtmlUnitRunStrategy implements TestRunStrategy {
private void init() {
webClient.set(new WebClient(BrowserVersion.CHROME));
try {
page.set(webClient.get().<HtmlPage>getPage("about:blank"));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private String readFile(File file) throws IOException {