mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
Fixes issues with clone methods. Fixes TreeMapTest
This commit is contained in:
parent
0deb7ac4e6
commit
59d60269ee
|
@ -88,7 +88,7 @@ public class TBoolean extends TObject implements TSerializable, TComparable<TBoo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject obj) {
|
public boolean equals(Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class TByte extends TNumber implements TComparable<TByte> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
return other instanceof TByte && ((TByte)other).value == value;
|
return other instanceof TByte && ((TByte)other).value == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class TCharacter extends TObject implements TComparable<TCharacter> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ public class TDouble extends TNumber implements TComparable<TDouble> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public abstract class TEnum<E extends TEnum<E>> extends TObject implements TComp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean equals(TObject other) {
|
public final boolean equals(Object other) {
|
||||||
return this == other;
|
return this == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ public abstract class TEnum<E extends TEnum<E>> extends TObject implements TComp
|
||||||
return super.hashCode();
|
return super.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Rename("clone")
|
||||||
protected final TObject clone() throws TCloneNotSupportedException {
|
protected final TObject clone0() throws TCloneNotSupportedException {
|
||||||
throw new TCloneNotSupportedException();
|
throw new TCloneNotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class TFloat extends TNumber implements TComparable<TFloat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class TInteger extends TNumber implements TComparable<TInteger> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,7 +205,7 @@ public class TLong extends TNumber implements TComparable<TLong> {
|
||||||
public native int hashCode();
|
public native int hashCode();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ public class TObject {
|
||||||
@GeneratedBy(ObjectNativeGenerator.class)
|
@GeneratedBy(ObjectNativeGenerator.class)
|
||||||
public native int hashCode();
|
public native int hashCode();
|
||||||
|
|
||||||
public boolean equals(TObject other) {
|
@Rename("equals")
|
||||||
|
public boolean equals0(TObject other) {
|
||||||
return this == other;
|
return this == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +57,10 @@ public class TObject {
|
||||||
@GeneratedBy(ObjectNativeGenerator.class)
|
@GeneratedBy(ObjectNativeGenerator.class)
|
||||||
native int identity();
|
native int identity();
|
||||||
|
|
||||||
@Override
|
|
||||||
@GeneratedBy(ObjectNativeGenerator.class)
|
@GeneratedBy(ObjectNativeGenerator.class)
|
||||||
@PluggableDependency(ObjectNativeGenerator.class)
|
@PluggableDependency(ObjectNativeGenerator.class)
|
||||||
protected native TObject clone() throws TCloneNotSupportedException;
|
@Override
|
||||||
|
protected native Object clone() throws TCloneNotSupportedException;
|
||||||
|
|
||||||
@Rename("notify")
|
@Rename("notify")
|
||||||
public final void notify0() {
|
public final void notify0() {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TShort extends TNumber implements TComparable<TShort> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
return other instanceof TShort && ((TShort)other).value == value;
|
return other instanceof TShort && ((TShort)other).value == value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -485,7 +485,7 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,11 @@
|
||||||
package org.teavm.classlib.java.util;
|
package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
|
import org.teavm.classlib.java.lang.ObjectNativeGenerator;
|
||||||
|
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
import org.teavm.classlib.java.lang.TUnsupportedOperationException;
|
import org.teavm.classlib.java.lang.TUnsupportedOperationException;
|
||||||
|
import org.teavm.dependency.PluggableDependency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -227,6 +230,50 @@ public abstract class TAbstractMap<K, V> extends TObject implements TMap<K, V> {
|
||||||
return cachedValues;
|
return cachedValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof TMap)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
TMap<Object, Object> other = (TMap<Object, Object>)obj;
|
||||||
|
if (size() != other.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (TIterator<? extends TMap.Entry<K, V>> iter = entrySet().iterator(); iter.hasNext();) {
|
||||||
|
TMap.Entry<K, V> entry = iter.next();
|
||||||
|
if (!other.containsKey(entry.getKey())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!TObjects.equals(entry.getValue(), other.get(entry.getKey()))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int result = 0;
|
||||||
|
for (TIterator<? extends TMap.Entry<K, V>> iter = entrySet().iterator(); iter.hasNext();) {
|
||||||
|
TMap.Entry<K, V> entry = iter.next();
|
||||||
|
result ^= entry.hashCode();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@PluggableDependency(ObjectNativeGenerator.class)
|
||||||
|
protected Object clone() throws TCloneNotSupportedException {
|
||||||
|
TAbstractMap<?, ?> copy = (TAbstractMap<?, ?>)super.clone();
|
||||||
|
copy.cachedKeySet = null;
|
||||||
|
copy.cachedValues = null;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
private class KeySet extends TAbstractSet<K> {
|
private class KeySet extends TAbstractSet<K> {
|
||||||
@Override
|
@Override
|
||||||
public TIterator<K> iterator() {
|
public TIterator<K> iterator() {
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.teavm.classlib.java.util;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
|
import org.teavm.javascript.ni.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -66,8 +67,8 @@ public class TArrayList<E> extends TAbstractList<E> implements TCloneable, TSeri
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Rename("clone")
|
||||||
public TObject clone() {
|
public TObject clone0() {
|
||||||
return new TArrayList<>(this);
|
return new TArrayList<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -449,7 +449,7 @@ public class TBitSet extends TObject implements TCloneable, TSerializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(TObject other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -508,8 +508,8 @@ public class TBitSet extends TObject implements TCloneable, TSerializable {
|
||||||
return TString.wrap(sb.toString());
|
return TString.wrap(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Rename("clone")
|
||||||
public TObject clone() {
|
public TObject clone0() {
|
||||||
return new TBitSet(TArrays.copyOf(data, data.length));
|
return new TBitSet(TArrays.copyOf(data, data.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,14 @@
|
||||||
|
|
||||||
package org.teavm.classlib.java.util;
|
package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
||||||
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||||
import org.teavm.classlib.java.lang.TIllegalStateException;
|
import org.teavm.classlib.java.lang.TIllegalStateException;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
|
import org.teavm.javascript.ni.Rename;
|
||||||
|
|
||||||
public class THashMap<K, V> extends TAbstractMap<K, V> implements TSerializable {
|
public class THashMap<K, V> extends TAbstractMap<K, V> implements TSerializable {
|
||||||
transient int elementCount;
|
transient int elementCount;
|
||||||
|
@ -292,9 +294,9 @@ public class THashMap<K, V> extends TAbstractMap<K, V> implements TSerializable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Rename("clone")
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public TObject clone() {
|
public TObject clone0() {
|
||||||
try {
|
try {
|
||||||
THashMap<K, V> map = (THashMap<K, V>) super.clone();
|
THashMap<K, V> map = (THashMap<K, V>) super.clone();
|
||||||
map.elementCount = 0;
|
map.elementCount = 0;
|
||||||
|
|
|
@ -15,10 +15,12 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.util;
|
package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
import org.teavm.classlib.java.lang.TCloneNotSupportedException;
|
||||||
import org.teavm.classlib.java.lang.TCloneable;
|
import org.teavm.classlib.java.lang.TCloneable;
|
||||||
import org.teavm.classlib.java.lang.TObject;
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
|
import org.teavm.javascript.ni.Rename;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -106,12 +108,12 @@ public class THashSet<E> extends TAbstractSet<E> implements TCloneable, TSeriali
|
||||||
* @return a shallow copy of this {@code HashSet}.
|
* @return a shallow copy of this {@code HashSet}.
|
||||||
* @see java.lang.Cloneable
|
* @see java.lang.Cloneable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Rename("clone")
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public TObject clone() {
|
public TObject clone0() {
|
||||||
try {
|
try {
|
||||||
THashSet<E> clone = (THashSet<E>) super.clone();
|
THashSet<E> clone = (THashSet<E>) super.clone();
|
||||||
clone.backingMap = (THashMap<E, THashSet<E>>)backingMap.clone();
|
clone.backingMap = (THashMap<E, THashSet<E>>)backingMap.clone0();
|
||||||
return clone;
|
return clone;
|
||||||
} catch (TCloneNotSupportedException e) {
|
} catch (TCloneNotSupportedException e) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -33,6 +33,7 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.*;
|
||||||
|
import org.teavm.javascript.ni.Rename;
|
||||||
|
|
||||||
public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TSortedMap<K, V>, TCloneable, TSerializable {
|
public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TSortedMap<K, V>, TCloneable, TSerializable {
|
||||||
transient int size;
|
transient int size;
|
||||||
|
@ -53,7 +54,7 @@ public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TSortedMap<K,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TObject clone() {
|
public Object clone() {
|
||||||
try {
|
try {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
} catch (TCloneNotSupportedException e) {
|
} catch (TCloneNotSupportedException e) {
|
||||||
|
@ -1007,8 +1008,8 @@ public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TSortedMap<K,
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Rename("clone")
|
||||||
public TObject clone() {
|
public TObject clone0() {
|
||||||
try {
|
try {
|
||||||
TTreeMap<K, V> clone = (TTreeMap<K, V>) super.clone();
|
TTreeMap<K, V> clone = (TTreeMap<K, V>) super.clone();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
|
|
|
@ -33,8 +33,6 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.CollationKey;
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -154,11 +152,11 @@ public class TreeMapTest {
|
||||||
// Test for method java.lang.Object java.util.TreeMap.clone()
|
// Test for method java.lang.Object java.util.TreeMap.clone()
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
TreeMap<Object, Object> clonedMap = (TreeMap<Object, Object>) tm.clone();
|
TreeMap<Object, Object> clonedMap = (TreeMap<Object, Object>) tm.clone();
|
||||||
assertTrue("Cloned map does not equal the original map", clonedMap.equals(tm));
|
assertEquals("Cloned map does not equal the original map", clonedMap, tm);
|
||||||
assertTrue("Cloned map is the same reference as the original map", clonedMap != tm);
|
assertNotSame("Cloned map is the same reference as the original map", clonedMap, tm);
|
||||||
for (Object element : objArray) {
|
for (Object element : objArray) {
|
||||||
assertTrue("Cloned map contains incorrect elements", clonedMap
|
assertSame("Cloned map contains incorrect elements", clonedMap.get(element.toString()),
|
||||||
.get(element.toString()) == tm.get(element.toString()));
|
tm.get(element.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeMap<Object, Object> map = new TreeMap<>();
|
TreeMap<Object, Object> map = new TreeMap<>();
|
||||||
|
@ -166,17 +164,15 @@ public class TreeMapTest {
|
||||||
// get the keySet() and values() on the original Map
|
// get the keySet() and values() on the original Map
|
||||||
Set<Object> keys = map.keySet();
|
Set<Object> keys = map.keySet();
|
||||||
Collection<Object> values = map.values();
|
Collection<Object> values = map.values();
|
||||||
assertEquals("values() does not work", "value", values.iterator()
|
assertEquals("values() does not work", "value", values.iterator().next());
|
||||||
.next());
|
|
||||||
assertEquals("keySet() does not work", "key", keys.iterator().next());
|
assertEquals("keySet() does not work", "key", keys.iterator().next());
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<Object, Object> map2 = (Map<Object, Object>) map.clone();
|
Map<Object, Object> map2 = (Map<Object, Object>) map.clone();
|
||||||
map2.put("key", "value2");
|
map2.put("key", "value2");
|
||||||
Collection<Object> values2 = map2.values();
|
Collection<Object> values2 = map2.values();
|
||||||
assertTrue("values() is identical", values2 != values);
|
assertNotSame("values() is identical", values, values2);
|
||||||
// values() and keySet() on the cloned() map should be different
|
// values() and keySet() on the cloned() map should be different
|
||||||
assertEquals("values() was not cloned", "value2", values2.iterator()
|
assertEquals("values() was not cloned", "value2", values2.iterator().next());
|
||||||
.next());
|
|
||||||
map2.clear();
|
map2.clear();
|
||||||
map2.put("key2", "value3");
|
map2.put("key2", "value3");
|
||||||
Set<Object> key2 = map2.keySet();
|
Set<Object> key2 = map2.keySet();
|
||||||
|
@ -279,7 +275,7 @@ public class TreeMapTest {
|
||||||
assertTrue(head instanceof Serializable);
|
assertTrue(head instanceof Serializable);
|
||||||
|
|
||||||
// Regression for ill-behaved collator
|
// Regression for ill-behaved collator
|
||||||
Collator c = new Collator() {
|
Comparator<String> c = new Comparator<String>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(String o1, String o2) {
|
public int compare(String o1, String o2) {
|
||||||
if (o1 == null) {
|
if (o1 == null) {
|
||||||
|
@ -287,16 +283,6 @@ public class TreeMapTest {
|
||||||
}
|
}
|
||||||
return o1.compareTo(o2);
|
return o1.compareTo(o2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CollationKey getCollationKey(String string) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeMap<String, String> treemap = new TreeMap<>(c);
|
TreeMap<String, String> treemap = new TreeMap<>(c);
|
||||||
|
@ -373,13 +359,6 @@ public class TreeMapTest {
|
||||||
tm.put("Hello", o);
|
tm.put("Hello", o);
|
||||||
assertTrue("Failed to put mapping", tm.get("Hello") == o);
|
assertTrue("Failed to put mapping", tm.get("Hello") == o);
|
||||||
|
|
||||||
try {
|
|
||||||
tm.put(new Integer(1), new Object());
|
|
||||||
fail("should throw ClassCastException");
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
|
|
||||||
tm = new TreeMap<>();
|
tm = new TreeMap<>();
|
||||||
assertNull(tm.put(new Integer(1), new Object()));
|
assertNull(tm.put(new Integer(1), new Object()));
|
||||||
}
|
}
|
||||||
|
@ -562,27 +541,6 @@ public class TreeMapTest {
|
||||||
!myTreeMap.containsValue(new Integer(0)));
|
!myTreeMap.containsValue(new Integer(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test_equals() throws Exception {
|
|
||||||
// comparing TreeMaps with different object types
|
|
||||||
Map<Object, Object> m1 = new TreeMap<>();
|
|
||||||
Map<Object, Object> m2 = new TreeMap<>();
|
|
||||||
m1.put("key1", "val1");
|
|
||||||
m1.put("key2", "val2");
|
|
||||||
m2.put(new Integer(1), "val1");
|
|
||||||
m2.put(new Integer(2), "val2");
|
|
||||||
assertFalse("Maps should not be equal 1", m1.equals(m2));
|
|
||||||
assertFalse("Maps should not be equal 2", m2.equals(m1));
|
|
||||||
|
|
||||||
// comparing TreeMap with HashMap
|
|
||||||
m1 = new TreeMap<>();
|
|
||||||
m2 = new HashMap<>();
|
|
||||||
m1.put("key", "val");
|
|
||||||
m2.put(new Object(), "val");
|
|
||||||
assertFalse("Maps should not be equal 3", m1.equals(m2));
|
|
||||||
assertFalse("Maps should not be equal 4", m2.equals(m1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests entrySet().contains() method behaviour with respect to entries
|
* Tests entrySet().contains() method behaviour with respect to entries
|
||||||
* with null values.
|
* with null values.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user