Makes tests to be runnable both on JVM and TeaVM

This commit is contained in:
konsoletyper 2013-12-03 22:38:22 +04:00
parent d3063e7811
commit 59615f3165
6 changed files with 21 additions and 18 deletions

View File

@ -7,7 +7,7 @@ import org.junit.Test;
*
* @author Alexey Andreev
*/
class TClassTests {
public class ClassTests {
@Test
public void classNameEvaluated() {
assertEquals("java.lang.Object", Object.class.getName());

View File

@ -7,7 +7,7 @@ import org.junit.Test;
*
* @author Alexey Andreev
*/
class TObjectTests {
public class ObjectTests {
@Test
public void objectCreated() {
Object a = new Object();

View File

@ -7,30 +7,30 @@ import org.junit.Test;
*
* @author Alexey Andreev
*/
class TStringBuilderTests {
public class StringBuilderTests {
public void integerAppended() {
TStringBuilder sb = new TStringBuilder();
StringBuilder sb = new StringBuilder();
sb.append(23);
assertEquals("23", sb.toString());
}
@Test
public void largeIntegerAppended() {
TStringBuilder sb = new TStringBuilder();
StringBuilder sb = new StringBuilder();
sb.append(123456);
assertEquals("123456", sb.toString());
}
@Test
public void negativeIntegerAppended() {
TStringBuilder sb = new TStringBuilder();
StringBuilder sb = new StringBuilder();
sb.append(-23);
assertEquals("-23", sb.toString());
}
@Test
public void maxIntegerAppended() {
TStringBuilder sb = new TStringBuilder();
StringBuilder sb = new StringBuilder();
sb.append(2147483647);
assertEquals("2147483647", sb.toString());
}

View File

@ -7,7 +7,7 @@ import org.junit.Test;
*
* @author Alexey Andreev <konsoletyper@gmail.com>
*/
class TStringTests {
public class StringTests {
@Test
public void charsExtracted() {
String str = "123";

View File

@ -7,14 +7,14 @@ import org.junit.Test;
*
* @author Alexey Andreev
*/
class TSystemTests {
public class SystemTests {
@Test
public void copiesArray() {
TObject a = new TObject();
TObject b = new TObject();
TObject[] src = { a, b, a };
TObject[] dest = new TObject[3];
TSystem.arraycopy(TObject.wrap(src), 0, TObject.wrap(dest), 0, 3);
Object a = new Object();
Object b = new Object();
Object[] src = { a, b, a };
Object[] dest = new Object[3];
System.arraycopy(src, 0, dest, 0, 3);
assertSame(a, dest[0]);
assertSame(b, dest[1]);
assertSame(a, dest[2]);
@ -22,21 +22,21 @@ class TSystemTests {
@Test(expected = IndexOutOfBoundsException.class)
public void failsToCopyArraysWithInvalidIndexes() {
TSystem.arraycopy(TObject.wrap(new TObject[0]), 0, TObject.wrap(new TObject[0]), 0, 1);
System.arraycopy(new Object[0], 0, new TObject[0], 0, 1);
}
@Test(expected = ArrayStoreException.class)
public void failsToCopyArraysWithIncompatibleElements() {
TSystem.arraycopy(TObject.wrap(new TObject[1]), 0, TObject.wrap(new int[1]), 0, 1);
System.arraycopy(new Object[1], 0, new int[1], 0, 1);
}
@Test(expected = NullPointerException.class)
public void failsToCopyFromNullSource() {
TSystem.arraycopy(null, 0, TObject.wrap(new int[1]), 0, 1);
System.arraycopy(null, 0, new int[1], 0, 1);
}
@Test(expected = NullPointerException.class)
public void failsToCopyToNullTarget() {
TSystem.arraycopy(TObject.wrap(new TObject[1]), 0, null, 0, 1);
System.arraycopy(new TObject[1], 0, null, 0, 1);
}
}

View File

@ -46,6 +46,9 @@ public class ClasslibTestGenerator {
writer = new SourceWriter(naming);
renderer = new Renderer(writer, classSource);
DependencyChecker dependencyChecker = new DependencyChecker(classSource);
for (int i = 0; i < testClasses.length; ++i) {
testClasses[i] = "org.teavm.classlib." + testClasses[i];
}
for (String testClass : testClasses) {
ClassHolder classHolder = classSource.getClassHolder(testClass);
findTests(classHolder);