mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fixes exception with Long.toString method. Fixes incorrect getMessage
invocation from unit test runner.
This commit is contained in:
parent
87262f2e97
commit
b21e1b4dd5
|
@ -190,7 +190,7 @@ public class TLong extends TNumber implements TComparable<TLong> {
|
|||
return toString(i, 2);
|
||||
}
|
||||
|
||||
public TString toString(long value) {
|
||||
public static TString toString(long value) {
|
||||
return TString.wrap(new TStringBuilder().append(value).toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright 2014 Alexey Andreev.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.tooling;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||
*/
|
||||
final class ExceptionHelper {
|
||||
private ExceptionHelper() {
|
||||
}
|
||||
|
||||
public static String showException(Throwable e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
|
@ -290,10 +290,9 @@ public class TeaVMTestTool {
|
|||
}
|
||||
File file = new File(outputDir, targetName);
|
||||
try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) {
|
||||
MethodReference cons = new MethodReference(methodRef.getClassName(),
|
||||
new MethodDescriptor("<init>", ValueType.VOID));
|
||||
MethodReference exceptionMsg = new MethodReference("java.lang.Throwable", "getMessage",
|
||||
ValueType.object("java.lang.String"));
|
||||
MethodReference cons = new MethodReference(methodRef.getClassName(), "<init>", ValueType.VOID);
|
||||
MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException",
|
||||
Throwable.class, String.class);
|
||||
vm.entryPoint("initInstance", cons);
|
||||
vm.entryPoint("runTest", methodRef).withValue(0, cons.getClassName());
|
||||
vm.entryPoint("extractException", exceptionMsg);
|
||||
|
|
|
@ -19,15 +19,14 @@ import org.teavm.dependency.*;
|
|||
import org.teavm.model.ClassReader;
|
||||
import org.teavm.model.ClassReaderSource;
|
||||
import org.teavm.model.MethodReference;
|
||||
import org.teavm.model.ValueType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
class TestExceptionDependency implements DependencyListener {
|
||||
private MethodReference getMessageRef = new MethodReference("java.lang.Throwable", "getMessage",
|
||||
ValueType.object("java.lang.String"));
|
||||
private MethodReference getMessageRef = new MethodReference(ExceptionHelper.class, "showException",
|
||||
Throwable.class, String.class);
|
||||
private DependencyNode allClasses;
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +58,7 @@ class TestExceptionDependency implements DependencyListener {
|
|||
@Override
|
||||
public void methodAchieved(DependencyAgent agent, MethodDependency method) {
|
||||
if (method.getReference().equals(getMessageRef)) {
|
||||
allClasses.connect(method.getVariable(0));
|
||||
allClasses.connect(method.getVariable(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user