Clarify that JSONObject.keySet() is immutable, fix bad test code that was taking advantage of the old implementation details.
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4620 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/json/client/JSONObject.java b/user/src/com/google/gwt/json/client/JSONObject.java
index 17233ff..bb6867a 100644
--- a/user/src/com/google/gwt/json/client/JSONObject.java
+++ b/user/src/com/google/gwt/json/client/JSONObject.java
@@ -110,7 +110,8 @@
}
/**
- * Returns the set of properties defined on this JSONObject.
+ * Returns the set of properties defined on this JSONObject. The returned set
+ * is immutable.
*/
public Set<String> keySet() {
final String[] keys = computeKeys();
diff --git a/user/test/com/google/gwt/json/client/JSONTest.java b/user/test/com/google/gwt/json/client/JSONTest.java
index de9f9f0..c10751f 100644
--- a/user/test/com/google/gwt/json/client/JSONTest.java
+++ b/user/test/com/google/gwt/json/client/JSONTest.java
@@ -55,14 +55,14 @@
private static void assertJSONObjectEquals(JSONObject expected,
JSONObject actual) {
Set<String> actKeys = actual.keySet();
- for (String key : expected.keySet()) {
- actKeys.remove(key);
+ Set<String> expKeys = expected.keySet();
+ assertEquals(expKeys.size(), actKeys.size());
+ for (String key : expKeys) {
assertTrue(actual.containsKey(key));
JSONValue expValue = expected.get(key);
JSONValue actValue = actual.get(key);
assertJSONValueEquals(expValue, actValue);
}
- assertEquals(0, actKeys.size());
}
private static void assertJSONValueEquals(JSONValue expected, JSONValue actual) {