mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-08 07:54:11 -08:00
Fixes VectorTest passing
This commit is contained in:
parent
9a2d1b5e91
commit
3ce1eb4b19
|
@ -15,10 +15,8 @@
|
|||
*/
|
||||
package org.teavm.classlib.java.util;
|
||||
|
||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||
import org.teavm.classlib.java.lang.TIllegalStateException;
|
||||
import org.teavm.classlib.java.lang.TIndexOutOfBoundsException;
|
||||
import org.teavm.classlib.java.lang.TUnsupportedOperationException;
|
||||
import org.teavm.classlib.java.lang.*;
|
||||
import org.teavm.javascript.ni.Rename;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,9 +54,11 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
|
|||
throw new TIllegalStateException();
|
||||
}
|
||||
checkConcurrentModification();
|
||||
TAbstractList.this.remove(index - 1);
|
||||
TAbstractList.this.remove(removeIndex);
|
||||
modCount = TAbstractList.this.modCount;
|
||||
--index;
|
||||
if (removeIndex < index) {
|
||||
--index;
|
||||
}
|
||||
--size;
|
||||
removeIndex = -1;
|
||||
}
|
||||
|
@ -159,6 +159,36 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
||||
for (TIterator<? extends E> iter = iterator(); iter.hasNext();) {
|
||||
E elem = iter.next();
|
||||
hashCode = 31 * hashCode + (elem != null ? elem.hashCode() : 0);
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Rename("equals")
|
||||
public boolean equals0(TObject other) {
|
||||
if (!(other instanceof TList)) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
TList<Object> list = (TList<Object>)other;
|
||||
if (size() != list.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
if (!TObjects.equals(get(i), list.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private class TListIteratorImpl implements TListIterator<E> {
|
||||
private int i;
|
||||
private int j;
|
||||
|
@ -187,6 +217,9 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
|
|||
}
|
||||
checkConcurrentModification();
|
||||
TAbstractList.this.remove(j);
|
||||
if (j < i) {
|
||||
--i;
|
||||
}
|
||||
--sz;
|
||||
lastModCount = modCount;
|
||||
}
|
||||
|
@ -215,9 +248,6 @@ public abstract class TAbstractList<E> extends TAbstractCollection<E> implements
|
|||
TAbstractList.this.set(j, e);
|
||||
}
|
||||
@Override public void add(E e) {
|
||||
if (j == -1) {
|
||||
throw new TIllegalStateException();
|
||||
}
|
||||
TAbstractList.this.add(i++, e);
|
||||
lastModCount = modCount;
|
||||
j = -1;
|
||||
|
|
|
@ -1103,12 +1103,12 @@ public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TCloneable, TS
|
|||
|
||||
@Override
|
||||
public TSortedSet<K> headSet(K toElement) {
|
||||
return map.headMap(toElement, true).navigableKeySet();
|
||||
return map.headMap(toElement, false).navigableKeySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TSortedSet<K> tailSet(K fromElement) {
|
||||
return map.headMap(fromElement, false).navigableKeySet();
|
||||
return map.headMap(fromElement, true).navigableKeySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,12 +43,20 @@ import org.junit.Test;
|
|||
import org.teavm.classlib.support.Support_ListTest;
|
||||
|
||||
public class VectorTest {
|
||||
|
||||
private Vector<Object> tVector = new Vector<>();
|
||||
|
||||
Object[] objArray;
|
||||
|
||||
private String vString = "[Test 0, Test 1, Test 2, Test 3, Test 4, Test 5, Test 6, Test 7, Test 8, Test 9, Test 10, Test 11, Test 12, Test 13, Test 14, Test 15, Test 16, Test 17, Test 18, Test 19, Test 20, Test 21, Test 22, Test 23, Test 24, Test 25, Test 26, Test 27, Test 28, Test 29, Test 30, Test 31, Test 32, Test 33, Test 34, Test 35, Test 36, Test 37, Test 38, Test 39, Test 40, Test 41, Test 42, Test 43, Test 44, Test 45, Test 46, Test 47, Test 48, Test 49, Test 50, Test 51, Test 52, Test 53, Test 54, Test 55, Test 56, Test 57, Test 58, Test 59, Test 60, Test 61, Test 62, Test 63, Test 64, Test 65, Test 66, Test 67, Test 68, Test 69, Test 70, Test 71, Test 72, Test 73, Test 74, Test 75, Test 76, Test 77, Test 78, Test 79, Test 80, Test 81, Test 82, Test 83, Test 84, Test 85, Test 86, Test 87, Test 88, Test 89, Test 90, Test 91, Test 92, Test 93, Test 94, Test 95, Test 96, Test 97, Test 98, Test 99]";
|
||||
private String vString = "[Test 0, Test 1, Test 2, Test 3, Test 4, Test 5, Test 6, Test 7, Test 8, Test 9, " +
|
||||
"Test 10, Test 11, Test 12, Test 13, Test 14, Test 15, Test 16, Test 17, Test 18, Test 19, Test 20, " +
|
||||
"Test 21, Test 22, Test 23, Test 24, Test 25, Test 26, Test 27, Test 28, Test 29, Test 30, Test 31, " +
|
||||
"Test 32, Test 33, Test 34, Test 35, Test 36, Test 37, Test 38, Test 39, Test 40, Test 41, Test 42, " +
|
||||
"Test 43, Test 44, Test 45, Test 46, Test 47, Test 48, Test 49, Test 50, Test 51, Test 52, Test 53, " +
|
||||
"Test 54, Test 55, Test 56, Test 57, Test 58, Test 59, Test 60, Test 61, Test 62, Test 63, Test 64, " +
|
||||
"Test 65, Test 66, Test 67, Test 68, Test 69, Test 70, Test 71, Test 72, Test 73, Test 74, Test 75, " +
|
||||
"Test 76, Test 77, Test 78, Test 79, Test 80, Test 81, Test 82, Test 83, Test 84, Test 85, Test 86, " +
|
||||
"Test 87, Test 88, Test 89, Test 90, Test 91, Test 92, Test 93, Test 94, Test 95, Test 96, Test 97, " +
|
||||
"Test 98, Test 99]";
|
||||
|
||||
public VectorTest() {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
|
@ -62,16 +70,16 @@ public class VectorTest {
|
|||
|
||||
@Test
|
||||
public void test_Constructor() {
|
||||
// Test for method java.util.Vector()
|
||||
|
||||
Vector<Integer> tv = new Vector<>(100);
|
||||
for (int i = 0; i < 100; i++)
|
||||
for (int i = 0; i < 100; i++) {
|
||||
tv.addElement(i);
|
||||
}
|
||||
new Support_ListTest(tv).runTest();
|
||||
|
||||
tv = new Vector<>(200);
|
||||
for (int i = -50; i < 150; i++)
|
||||
for (int i = -50; i < 150; i++) {
|
||||
tv.addElement(i);
|
||||
}
|
||||
new Support_ListTest(tv.subList(50, 150)).runTest();
|
||||
|
||||
Vector<String> v = new Vector<>();
|
||||
|
|
Loading…
Reference in New Issue
Block a user