mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
More tests added
This commit is contained in:
parent
ac0df0ca6b
commit
c8528ef91a
|
@ -104,7 +104,7 @@ public class ObjectNativeGenerator implements Generator, DependencyPlugin {
|
|||
}
|
||||
|
||||
private void generateWrap(GeneratorContext context, SourceWriter writer) {
|
||||
writer.append("return ").append(context.getParameterName(1));
|
||||
writer.append("return ").append(context.getParameterName(1)).append(";").newLine();
|
||||
}
|
||||
|
||||
private void achieveWrap(DependencyChecker checker, MethodReference method) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable {
|
|||
} else {
|
||||
int pos = 10;
|
||||
int sz = 1;
|
||||
while (pos <= 1000000000 && pos <= value) {
|
||||
while (pos < 1000000000 && pos * 10 <= value) {
|
||||
pos *= 10;
|
||||
++sz;
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ class TAbstractStringBuilder extends TObject implements TSerializable {
|
|||
if (!positive) {
|
||||
buffer[length++] = '-';
|
||||
}
|
||||
pos /= 10;
|
||||
while (pos > 0) {
|
||||
buffer[length++] = (char)('0' + value / pos);
|
||||
value %= pos;
|
||||
|
|
|
@ -45,9 +45,4 @@ class TObjectTests {
|
|||
public void properInstanceDetected() {
|
||||
assertTrue(Object.class.isInstance(new Object()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alwaysFails() {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,30 @@ import org.junit.Test;
|
|||
* @author Alexey Andreev
|
||||
*/
|
||||
class TStringBuilderTests {
|
||||
@Test
|
||||
public void integerAppended() {
|
||||
TStringBuilder sb = new TStringBuilder();
|
||||
sb.append(23);
|
||||
assertEquals("23", sb.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void largeIntegerAppended() {
|
||||
TStringBuilder sb = new TStringBuilder();
|
||||
sb.append(123456);
|
||||
assertEquals("123456", sb.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void negativeIntegerAppended() {
|
||||
TStringBuilder sb = new TStringBuilder();
|
||||
sb.append(-23);
|
||||
assertEquals("-23", sb.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxIntegerAppended() {
|
||||
TStringBuilder sb = new TStringBuilder();
|
||||
sb.append(2147483647);
|
||||
assertEquals("2147483647", sb.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ class TSystemTests {
|
|||
assertSame(a, dest[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
public void failsToCopyArraysWithInvalidIndexes() {
|
||||
TSystem.arraycopy(TObject.wrap(new TObject[0]), 0, TObject.wrap(new TObject[0]), 0, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = ArrayStoreException.class)
|
||||
public void failsToCopyArraysWithIncompatibleElements() {
|
||||
TSystem.arraycopy(TObject.wrap(new TObject[1]), 0, TObject.wrap(new int[1]), 0, 1);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,16 @@ public class ClasslibTestGenerator {
|
|||
for (MethodReference method : methods) {
|
||||
writer.append("runTestCase(").appendClass(cls.getName()).append(".").appendMethod(cons)
|
||||
.append("(), \"" + method.getDescriptor().getName() + "\", \"").appendMethod(method)
|
||||
.append("\");").newLine();
|
||||
.append("\", [");
|
||||
MethodHolder methodHolder = classSource.getClassHolder(method.getClassName()).getMethod(
|
||||
method.getDescriptor());
|
||||
AnnotationHolder annot = methodHolder.getAnnotations().get("org.junit.Test");
|
||||
AnnotationValue expectedAnnot = annot.getValues().get("expected");
|
||||
if (expectedAnnot != null) {
|
||||
String className = ((ValueType.Object)expectedAnnot.getJavaClass()).getClassName();
|
||||
writer.appendClass(className);
|
||||
}
|
||||
writer.append("]);").newLine();
|
||||
}
|
||||
writer.outdent().append("})").newLine();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
currentTestReportBody = null;
|
||||
|
||||
runTestCase = function(instance, methodName, realMethodName) {
|
||||
runTestCase = function(instance, methodName, realMethodName, expectedExceptions) {
|
||||
var row = document.createElement("tr");
|
||||
currentTestReportBody.appendChild(row);
|
||||
var nameCell = document.createElement("td");
|
||||
|
@ -12,14 +12,33 @@ runTestCase = function(instance, methodName, realMethodName) {
|
|||
row.appendChild(exceptionCell);
|
||||
try {
|
||||
instance[realMethodName]();
|
||||
if (expectedExceptions.length > 0) {
|
||||
statusCell.appendChild(document.createTextNode("expected exception not thrown"));
|
||||
} else {
|
||||
statusCell.appendChild(document.createTextNode("ok"));
|
||||
}
|
||||
} catch (e) {
|
||||
if (isExpectedException(e, expectedExceptions)) {
|
||||
statusCell.appendChild(document.createTextNode("ok"));
|
||||
} else {
|
||||
statusCell.appendChild(document.createTextNode("unexpected exception"));
|
||||
var exceptionText = document.createElement("pre");
|
||||
exceptionText.appendChild(document.createTextNode(e.stack));
|
||||
exceptionCell.appendChild(exceptionText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isExpectedException = function(e, expectedExceptions) {
|
||||
if (e.$javaException !== undefined) {
|
||||
for (var i = 0; i < expectedExceptions.length; ++i) {
|
||||
if (expectedExceptions[i] === e.$javaException.$class) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
testClass = function(className, classTests) {
|
||||
var table = document.createElement("table");
|
||||
|
|
|
@ -496,6 +496,7 @@ public class ProgramParser {
|
|||
NegateInstruction insn = new NegateInstruction(operandType);
|
||||
insn.setOperand(getVariable(operand));
|
||||
insn.setReceiver(getVariable(receiver));
|
||||
builder.add(insn);
|
||||
}
|
||||
|
||||
private void emitCast(ValueType targetType, int value, int result) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user