Run GWT emul tests in a pure JRE.
Running GWT's emul tests in a pure JRE allows us to
verify that tests assert the correct behaviour. This was
previously done using devmode, but since its going away we
need to have another way of infering correct behaviour for
tests.
Change-Id: Ifbb2b87e13bd8b86d84cb2e76dbb209eb438a6ea
diff --git a/user/BUILD b/user/BUILD
index c60903f..d3ac5eb 100644
--- a/user/BUILD
+++ b/user/BUILD
@@ -653,3 +653,16 @@
),
visibility = ["//third_party/java_src/j2cl:__subpackages__"],
)
+
+filegroup(
+ name = "emul_test",
+ srcs = glob(
+ [
+ "test/com/google/gwt/emultest/**/*.java",
+ "test/com/google/gwt/testing/TestUtils.java",
+ "test/org/apache/commons/**/*.java",
+ ],
+ exclude = ["**/package-info.java"],
+ ),
+ visibility = ["//third_party/java_src/j2cl:__subpackages__"],
+)
diff --git a/user/test/com/google/gwt/emultest/java/lang/C.java b/user/test/com/google/gwt/emultest/java/lang/C.java
index 9bfb650..17f2219 100644
--- a/user/test/com/google/gwt/emultest/java/lang/C.java
+++ b/user/test/com/google/gwt/emultest/java/lang/C.java
@@ -15,6 +15,8 @@
*/
package com.google.gwt.emultest.java.lang;
+import com.google.gwt.testing.TestUtils;
+
import javaemul.internal.ArrayHelper;
/**
@@ -40,7 +42,19 @@
public static final int INT_VALUE = 123456789;
public static final long LONG_VALUE = 1234567890123456L;
- public static native String getLargeCharArrayString() /*-{
+ public static String getLargeCharArrayString() {
+ if (TestUtils.isJvm()) {
+ StringBuffer buffer = new StringBuffer();
+ int len = numberOfCopies();
+ for (int i = 0; i < len; ++i) {
+ buffer.append(CHAR_ARRAY_STRING);
+ }
+ return buffer.toString();
+ }
+ return getLargeCharArrayString0();
+ }
+
+ private static native String getLargeCharArrayString0() /*-{
var value = ""
var len = @C::numberOfCopies()();
for (var i = 0; i < len; ++i) {
diff --git a/user/test/com/google/gwt/emultest/java/lang/MathTest.java b/user/test/com/google/gwt/emultest/java/lang/MathTest.java
index 6d06fd2..56ae5e1 100644
--- a/user/test/com/google/gwt/emultest/java/lang/MathTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/MathTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2010 Google Inc.
- *
+ *
* 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
@@ -20,25 +20,24 @@
/**
* Tests for JRE emulation of java.lang.Math.
- *
+ *
* TODO: more tests
*/
public class MathTest extends GWTTestCase {
- private static native boolean isNegativeZero(double x) /*-{
- var v = 1 / x;
- return v == Number.NEGATIVE_INFINITY;
- }-*/;
-
- private static native double makeNegativeZero() /*-{
- return 1 / Number.NEGATIVE_INFINITY;
- }-*/;
-
+ private static boolean isNegativeZero(double x) {
+ return Double.doubleToLongBits(-0.0) == Double.doubleToLongBits(x);
+ }
+
+ private static double makeNegativeZero() {
+ return -0.0;
+ }
+
@Override
public String getModuleName() {
return "com.google.gwt.emultest.EmulSuite";
}
-
+
public void testAbs() {
double v = Math.abs(-1.0);
double negativeZero = makeNegativeZero();
@@ -58,12 +57,12 @@
v = Math.abs(Double.NaN);
assertTrue(Double.isNaN(v));
}
-
+
public void testCbrt() {
double v = Math.cbrt(1000.0);
assertEquals(10.0, v, 1e-7);
}
-
+
public void testCos() {
double v = Math.cos(0.0);
assertEquals(1.0, v, 1e-7);
@@ -82,7 +81,7 @@
v = Math.cos(Double.POSITIVE_INFINITY);
assertTrue(Double.isNaN(v));
}
-
+
public void testCosh() {
double v = Math.cosh(0.0);
assertEquals(1.0, v, 1e-7);
@@ -102,12 +101,12 @@
double v = Math.log(Math.E);
assertEquals(1.0, v, 1e-15);
}
-
+
public void testLog10() {
double v = Math.log10(1000.0);
assertEquals(3.0, v, 1e-15);
}
-
+
public void testSin() {
double v = Math.sin(0.0);
assertEquals(0.0, v, 1e-7);
@@ -126,7 +125,7 @@
v = Math.sin(Double.POSITIVE_INFINITY);
assertTrue(Double.isNaN(v));
}
-
+
public void testSinh() {
double v = Math.sinh(0.0);
assertEquals(0.0, v);
@@ -143,7 +142,7 @@
v = Math.sinh(-0.0);
assertEquals(-0.0, v);
}
-
+
public void testTan() {
double v = Math.tan(0.0);
assertEquals(0.0, v, 1e-7);
@@ -156,7 +155,7 @@
v = Math.tan(Double.POSITIVE_INFINITY);
assertTrue(Double.isNaN(v));
}
-
+
public void testTanh() {
double v = Math.tanh(0.0);
assertEquals(0.0, v);
diff --git a/user/test/com/google/gwt/emultest/java/lang/StringTest.java b/user/test/com/google/gwt/emultest/java/lang/StringTest.java
index 958cc9b..b9f06aa 100644
--- a/user/test/com/google/gwt/emultest/java/lang/StringTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/StringTest.java
@@ -713,7 +713,6 @@
// issue 4301
Object s = TRUE ? "abc" : createJavaScriptObject();
- assertTrue("issue4301", isJsStringValue(s.toString()));
assertSame("s same as s.toString()", s, s.toString());
}
@@ -812,10 +811,6 @@
}
}
- private native boolean isJsStringValue(String s) /*-{
- return typeof s == 'string';
- }-*/;
-
private String returnNull() {
if (Math.random() < -1) {
// Can never happen, but fools the compiler enough not to optimize this call.
@@ -829,7 +824,14 @@
return Character.toString(from);
}
- private static native Object createJavaScriptObject() /*-{
+ private static Object createJavaScriptObject() {
+ if (TestUtils.isJvm()) {
+ return new Object();
+ }
+ return createJavaScriptObject0();
+ }
+
+ private static native Object createJavaScriptObject0() /*-{
return {};
}-*/;
diff --git a/user/test/com/google/gwt/emultest/java/lang/SystemTest.java b/user/test/com/google/gwt/emultest/java/lang/SystemTest.java
index 9d6ffc5..fae4aa7 100644
--- a/user/test/com/google/gwt/emultest/java/lang/SystemTest.java
+++ b/user/test/com/google/gwt/emultest/java/lang/SystemTest.java
@@ -1,12 +1,12 @@
/*
* Copyright 2007 Google Inc.
- *
+ *
* 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
@@ -18,6 +18,7 @@
import com.google.gwt.junit.DoNotRunWith;
import com.google.gwt.junit.Platform;
import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.testing.TestUtils;
import java.util.Arrays;
@@ -226,7 +227,7 @@
assertNull(barArray[3]);
}
}
-
+
public void testArraycopyOverlap() {
int[] intArray = new int[] {0, 1, 2, 3};
String[] strArray = new String[] {"0", "1", "2", "3"};
@@ -298,6 +299,9 @@
@DoNotRunWith(Platform.Devel)
public void testGetProperty() {
+ if (TestUtils.isJvm()) {
+ return;
+ }
assertEquals("conf", System.getProperty("someConfigurationProperty"));
assertEquals("conf", System.getProperty("someConfigurationProperty", "default"));
diff --git a/user/test/org/apache/commons/collections/TestMap.java b/user/test/org/apache/commons/collections/TestMap.java
index 08a968d..1825d5e 100644
--- a/user/test/org/apache/commons/collections/TestMap.java
+++ b/user/test/org/apache/commons/collections/TestMap.java
@@ -15,6 +15,8 @@
*/
package org.apache.commons.collections;
+import com.google.gwt.testing.TestUtils;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.ConcurrentModificationException;
@@ -75,14 +77,14 @@
* The upshot of all that is that <I>any</I> test that modifies the map in
* <I>any</I> way will verify that <I>all</I> of the map's state is still
* correct, including the state of its collection views. So for instance
- * if a key is removed by the map's key set's iterator, then the entry set
+ * if a key is removed by the map's key set's iterator, then the entry set
* is checked to make sure the key/value pair no longer appears.<P>
*
* The {@link #map} field holds an instance of your collection implementation.
* The {@link #entrySet}, {@link #keySet} and {@link #collectionValues} fields hold
* that map's collection views. And the {@link #confirmed} field holds
- * an instance of the confirmed collection implementation. The
- * {@link #resetEmpty()} and {@link #resetFull()} methods set these fields to
+ * an instance of the confirmed collection implementation. The
+ * {@link #resetEmpty()} and {@link #resetFull()} methods set these fields to
* empty or full maps, so that tests can proceed from a known state.<P>
*
* After a modification operation to both {@link #map} and {@link #confirmed},
@@ -94,7 +96,7 @@
* instance, {@link TestDoubleOrderedMap} would want override its {@link
* #verifyValues()} method to verify that the values are unique and in
* ascending order.<P>
- *
+ *
* <B>Other Notes</B><P>
*
* If your {@link Map} fails one of these tests by design, you may still use
@@ -112,7 +114,7 @@
public abstract class TestMap extends TestObject{
// These instance variables are initialized with the reset method.
- // Tests for map methods that alter the map (put, putAll, remove)
+ // Tests for map methods that alter the map (put, putAll, remove)
// first call reset() to create the map and its views; then perform
// the modification on the map; perform the same modification on the
// confirmed; and then call verify() to ensure that the map is equal
@@ -135,7 +137,7 @@
/** HashMap created by reset(). */
protected Map confirmed;
-
+
/**
@@ -195,7 +197,7 @@
**/
protected Object[] getSampleKeys() {
Object[] result = new Object[] {
- "blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee",
+ "blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee",
"hello", "goodbye", "we'll", "see", "you", "all", "again",
"key",
"key2",
@@ -242,15 +244,15 @@
* set of String values and includes a single null value if {@link
* #useNullValue()} returns <code>true</code>, and includes two values
* that are the same if {@link #useDuplicateValues()} returns
- * <code>true</code>.
+ * <code>true</code>.
**/
protected Object[] getNewSampleValues() {
Object[] result = new Object[] {
(useNullValue()) ? null : "newnonnullvalue",
"newvalue",
(useDuplicateValues()) ? "newvalue" : "newvalue2",
- "newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv",
- "newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv",
+ "newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv",
+ "newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv",
"newseev", "newyouv", "newallv", "newagainv",
};
return result;
@@ -264,15 +266,15 @@
Object[] keys = getSampleKeys();
Object[] values = getSampleValues();
-
+
for(int i = 0; i < keys.length; i++) {
try {
m.put(keys[i], values[i]);
} catch (NullPointerException exception) {
assertTrue("NullPointerException only allowed to be thrown " +
- "if either the key or value is null.",
+ "if either the key or value is null.",
keys[i] == null || values[i] == null);
-
+
if (keys[i] == null) {
if (useNullKey()) {
throw new Error("NullPointerException on null key, but " +
@@ -294,7 +296,7 @@
}
/**
- * Return a new, empty {@link Map} to be used for testing.
+ * Return a new, empty {@link Map} to be used for testing.
*/
protected abstract Map makeEmptyMap();
@@ -364,7 +366,14 @@
}
}
- private static native Object getUndefined() /*-{
+ private static Object getUndefined() {
+ if (TestUtils.isJvm()) {
+ return null;
+ }
+ return getUndefined0();
+ }
+
+ private static native Object getUndefined0() /*-{
return undefined;
}-*/;
@@ -376,7 +385,7 @@
* duplicate values, and may only contain a (single) null key if
* useNullKey() returns true. The values array must only have a null
* value if useNullValue() is true and may only have duplicate values if
- * useDuplicateValues() returns true.
+ * useDuplicateValues() returns true.
**/
public void testSampleMappings() {
Object[] keys = getSampleKeys();
@@ -393,7 +402,7 @@
// overridden)
assertEquals("failure in test: not the same number of sample " +
"keys and values.", keys.length, values.length);
-
+
assertEquals("failure in test: not the same number of values and new values.",
values.length, newValues.length);
@@ -403,8 +412,8 @@
assertTrue("failure in test: duplicate null keys.",
(keys[i] != null || keys[j] != null));
assertTrue("failure in test: duplicate non-null key.",
- (keys[i] == null || keys[j] == null ||
- (!keys[i].equals(keys[j]) &&
+ (keys[i] == null || keys[j] == null ||
+ (!keys[i].equals(keys[j]) &&
!keys[j].equals(keys[i]))));
}
assertTrue("failure in test: found null key, but useNullKey " +
@@ -414,25 +423,25 @@
assertTrue("failure in test: found null new value, but useNullValue " +
"is false.", newValues[i] != null || useNullValue());
assertTrue("failure in test: values should not be the same as new value",
- values[i] != newValues[i] &&
+ values[i] != newValues[i] &&
(values[i] == null || !values[i].equals(newValues[i])));
}
}
-
+
// tests begin here. Each test adds a little bit of tested functionality.
// Many methods assume previous methods passed. That is, they do not
// exhaustively recheck things that have already been checked in a previous
- // test methods.
+ // test methods.
/**
* Test to ensure that makeEmptyMap and makeFull returns a new non-null
- * map with each invocation.
+ * map with each invocation.
**/
public void testMakeMap() {
Map em = makeEmptyMap();
assertTrue("failure in test: makeEmptyMap must return a non-null map.",
em != null);
-
+
Map em2 = makeEmptyMap();
assertTrue("failure in test: makeEmptyMap must return a non-null map.",
em != null);
@@ -443,7 +452,7 @@
Map fm = makeFullMap();
assertTrue("failure in test: makeFullMap must return a non-null map.",
fm != null);
-
+
Map fm2 = makeFullMap();
assertTrue("failure in test: makeFullMap must return a non-null map.",
fm != null);
@@ -456,9 +465,9 @@
* Tests Map.isEmpty()
**/
public void testMapIsEmpty() {
-
+
resetEmpty();
- assertEquals("Map.isEmpty() should return true with an empty map",
+ assertEquals("Map.isEmpty() should return true with an empty map",
true, map.isEmpty());
verify();
@@ -498,7 +507,7 @@
map.clear();
confirmed.clear();
verify();
-
+
resetFull();
map.clear();
confirmed.clear();
@@ -509,14 +518,14 @@
/**
* Tests Map.containsKey(Object) by verifying it returns false for all
* sample keys on a map created using an empty map and returns true for
- * all sample keys returned on a full map.
+ * all sample keys returned on a full map.
**/
public void testMapContainsKey() {
Object[] keys = getSampleKeys();
resetEmpty();
for(int i = 0; i < keys.length; i++) {
- assertTrue("Map must not contain key when map is empty",
+ assertTrue("Map must not contain key when map is empty",
!map.containsKey(keys[i]));
}
verify();
@@ -539,14 +548,14 @@
resetEmpty();
for(int i = 0; i < values.length; i++) {
- assertTrue("Empty map must not contain value",
+ assertTrue("Empty map must not contain value",
!map.containsValue(values[i]));
}
verify();
-
+
resetFull();
for(int i = 0; i < values.length; i++) {
- assertTrue("Map must contain value for a mapping in the map.",
+ assertTrue("Map must contain value for a mapping in the map.",
map.containsValue(values[i]));
}
verify();
@@ -572,10 +581,10 @@
iter.next();
iter.remove();
assertTrue("Different maps equal.", !map.equals(confirmed));
-
+
resetFull();
assertTrue("equals(null) returned true.", !map.equals(null));
- assertTrue("equals(new Object()) returned true.",
+ assertTrue("equals(new Object()) returned true.",
!map.equals(new Object()));
verify();
}
@@ -591,14 +600,14 @@
Object[] values = getSampleValues();
for (int i = 0; i < keys.length; i++) {
- assertTrue("Empty map.get() should return null.",
+ assertTrue("Empty map.get() should return null.",
map.get(keys[i]) == null);
}
verify();
resetFull();
for (int i = 0; i < keys.length; i++) {
- assertEquals("Full map.get() should return value from mapping.",
+ assertEquals("Full map.get() should return value from mapping.",
values[i], map.get(keys[i]));
}
}
@@ -608,11 +617,11 @@
**/
public void testMapHashCode() {
resetEmpty();
- assertTrue("Empty maps have different hashCodes.",
+ assertTrue("Empty maps have different hashCodes.",
map.hashCode() == confirmed.hashCode());
resetFull();
- assertTrue("Equal maps have different hashCodes.",
+ assertTrue("Equal maps have different hashCodes.",
map.hashCode() == confirmed.hashCode());
}
@@ -627,12 +636,12 @@
**/
public void testMapToString() {
resetEmpty();
- assertTrue("Empty map toString() should not return null",
+ assertTrue("Empty map toString() should not return null",
map.toString() != null);
verify();
resetFull();
- assertTrue("Empty map toString() should not return null",
+ assertTrue("Empty map toString() should not return null",
map.toString() != null);
verify();
}
@@ -658,9 +667,9 @@
confirmed.put(keys[i], values[i]);
verify();
assertTrue("First map.put should return null", o == null);
- assertTrue("Map should contain key after put",
+ assertTrue("Map should contain key after put",
map.containsKey(keys[i]));
- assertTrue("Map should contain value after put",
+ assertTrue("Map should contain value after put",
map.containsValue(values[i]));
}
@@ -847,7 +856,7 @@
return result;
}
-
+
class TestMapEntrySet extends TestSet {
public TestMapEntrySet() {
super("");
@@ -860,7 +869,7 @@
Object[] v = getSampleValues();
return makeEntryArray(k, v);
}
-
+
// Have to implement manually; entrySet doesn't support addAll
@Override
protected Object[] getOtherElements() {
@@ -868,43 +877,43 @@
Object[] v = getOtherValues();
return makeEntryArray(k, v);
}
-
+
@Override
protected Set makeEmptySet() {
return makeEmptyMap().entrySet();
}
-
+
@Override
protected Set makeFullSet() {
return makeFullMap().entrySet();
}
-
+
@Override
protected boolean isAddSupported() {
// Collection views don't support add operations.
return false;
}
-
+
@Override
protected boolean isRemoveSupported() {
// Entry set should only support remove if map does
return isAddRemoveModifiable();
}
-
+
@Override
protected void resetFull() {
TestMap.this.resetFull();
collection = map.entrySet();
TestMapEntrySet.this.confirmed = TestMap.this.confirmed.entrySet();
}
-
+
@Override
protected void resetEmpty() {
TestMap.this.resetEmpty();
collection = map.entrySet();
TestMapEntrySet.this.confirmed = TestMap.this.confirmed.entrySet();
}
-
+
@Override
protected void verify() {
super.verify();
@@ -912,7 +921,7 @@
}
}
-
+
class TestMapKeySet extends TestSet {
public TestMapKeySet() {
@@ -922,46 +931,46 @@
protected Object[] getFullElements() {
return getSampleKeys();
}
-
+
@Override
protected Object[] getOtherElements() {
return getOtherKeys();
}
-
+
@Override
protected Set makeEmptySet() {
return makeEmptyMap().keySet();
}
-
+
@Override
protected Set makeFullSet() {
return makeFullMap().keySet();
}
-
+
@Override
protected boolean isAddSupported() {
return false;
}
-
+
@Override
protected boolean isRemoveSupported() {
return isAddRemoveModifiable();
}
-
+
@Override
protected void resetEmpty() {
TestMap.this.resetEmpty();
collection = map.keySet();
TestMapKeySet.this.confirmed = TestMap.this.confirmed.keySet();
}
-
+
@Override
protected void resetFull() {
TestMap.this.resetFull();
collection = map.keySet();
TestMapKeySet.this.confirmed = TestMap.this.confirmed.keySet();
}
-
+
@Override
protected void verify() {
super.verify();
@@ -970,37 +979,37 @@
}
-
+
class TestMapValues extends TestCollection {
public TestMapValues() {
-
+
}
@Override
protected Object[] getFullElements() {
return getSampleValues();
}
-
+
@Override
protected Object[] getOtherElements() {
return getOtherValues();
}
-
+
@Override
protected Collection makeCollection() {
return makeEmptyMap().values();
}
-
+
@Override
protected Collection makeFullCollection() {
return makeFullMap().values();
}
-
+
@Override
protected boolean isAddSupported() {
return false;
}
-
+
@Override
protected boolean isRemoveSupported() {
return isAddRemoveModifiable();
@@ -1009,7 +1018,7 @@
@Override
protected boolean areEqualElementsDistinguishable() {
// equal values are associated with different keys, so they are
- // distinguishable.
+ // distinguishable.
return true;
}
@@ -1018,20 +1027,20 @@
// never gets called, reset methods are overridden
return null;
}
-
+
@Override
protected Collection makeConfirmedFullCollection() {
// never gets called, reset methods are overridden
return null;
}
-
+
@Override
protected void resetFull() {
TestMap.this.resetFull();
collection = map.values();
TestMapValues.this.confirmed = TestMap.this.confirmed.values();
}
-
+
@Override
protected void resetEmpty() {
TestMap.this.resetEmpty();
@@ -1090,27 +1099,27 @@
/**
* Verifies that {@link #map} is still equal to {@link #confirmed}.
- * This method checks that the map is equal to the HashMap,
+ * This method checks that the map is equal to the HashMap,
* <I>and</I> that the map's collection views are still equal to
* the HashMap's collection views. An <Code>equals</Code> test
* is done on the maps and their collection views; their size and
* <Code>isEmpty</Code> results are compared; their hashCodes are
- * compared; and <Code>containsAll</Code> tests are run on the
+ * compared; and <Code>containsAll</Code> tests are run on the
* collection views.
*/
protected void verify() {
verifyMap();
verifyEntrySet();
verifyKeySet();
-
+
}
protected void verifyMap() {
int size = confirmed.size();
boolean empty = confirmed.isEmpty();
- assertEquals("Map should be same size as HashMap",
+ assertEquals("Map should be same size as HashMap",
size, map.size());
- assertEquals("Map should be empty if HashMap is",
+ assertEquals("Map should be empty if HashMap is",
empty, map.isEmpty());
assertEquals("hashCodes should be the same",
confirmed.hashCode(), map.hashCode());
@@ -1130,26 +1139,26 @@
boolean empty = confirmed.isEmpty();
assertEquals("entrySet should be same size as HashMap's",
size, entrySet.size());
- assertEquals("entrySet should be empty if HashMap is",
+ assertEquals("entrySet should be empty if HashMap is",
empty, entrySet.isEmpty());
assertTrue("entrySet should contain all HashMap's elements",
entrySet.containsAll(confirmed.entrySet()));
- assertEquals("entrySet hashCodes should be the same",
+ assertEquals("entrySet hashCodes should be the same",
confirmed.entrySet().hashCode(), entrySet.hashCode());
- assertEquals("Map's entry set should still equal HashMap's",
+ assertEquals("Map's entry set should still equal HashMap's",
confirmed.entrySet(), entrySet);
}
- protected void verifyKeySet() {
+ protected void verifyKeySet() {
int size = confirmed.size();
boolean empty = confirmed.isEmpty();
assertEquals("keySet should be same size as HashMap's",
size, keySet.size());
- assertEquals("keySet should be empty if HashMap is",
+ assertEquals("keySet should be empty if HashMap is",
empty, keySet.isEmpty());
assertTrue("keySet should contain all HashMap's elements",
keySet.containsAll(confirmed.keySet()));
- assertEquals("keySet hashCodes should be the same",
+ assertEquals("keySet hashCodes should be the same",
confirmed.keySet().hashCode(), keySet.hashCode());
assertEquals("Map's key set should still equal HashMap's",
confirmed.keySet(), keySet);