Index: test/mjsunit/harmony/collections.js |
diff --git a/test/mjsunit/harmony/collections.js b/test/mjsunit/harmony/collections.js |
index f3db7ea2b70a9670fa7e63082b2022bbd57f2576..6698a334882f53ae80653b6491cbd2e3f521a313 100644 |
--- a/test/mjsunit/harmony/collections.js |
+++ b/test/mjsunit/harmony/collections.js |
@@ -313,4 +313,45 @@ TestBogusReceivers(bogusReceiversTestSet); |
// Stress Test |
// There is a proposed stress-test available at the es-discuss mailing list |
// which cannot be reasonably automated. Check it out by hand if you like: |
-// https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html |
+// https://mail.mozilla.org/pipermail/es-discuss/2011-May/014096.html |
+ |
+ |
+// Set and Map size getters |
+var setSizeDescriptor = Object.getOwnPropertyDescriptor(Set.prototype, 'size'); |
+assertEquals(undefined, setSizeDescriptor.value); |
+assertEquals(undefined, setSizeDescriptor.set); |
+assertTrue(setSizeDescriptor.get instanceof Function); |
+assertEquals(undefined, setSizeDescriptor.get.prototype); |
+assertFalse(setSizeDescriptor.enumerable); |
+assertTrue(setSizeDescriptor.configurable); |
+ |
+var s = new Set(); |
+assertFalse(s.hasOwnProperty('size')); |
+for (var i = 0; i < 10; i++) { |
+ assertEquals(i, s.size); |
+ s.add(i); |
+} |
+for (var i = 9; i >= 0; i--) { |
+ s.delete(i); |
+ assertEquals(i, s.size); |
+} |
+ |
+ |
+var mapSizeDescriptor = Object.getOwnPropertyDescriptor(Map.prototype, 'size'); |
+assertEquals(undefined, mapSizeDescriptor.value); |
+assertEquals(undefined, mapSizeDescriptor.set); |
+assertTrue(mapSizeDescriptor.get instanceof Function); |
+assertEquals(undefined, mapSizeDescriptor.get.prototype); |
+assertFalse(mapSizeDescriptor.enumerable); |
+assertTrue(mapSizeDescriptor.configurable); |
+ |
+var m = new Map(); |
+assertFalse(m.hasOwnProperty('size')); |
+for (var i = 0; i < 10; i++) { |
+ assertEquals(i, m.size); |
+ m.set(i, i); |
+} |
+for (var i = 9; i >= 0; i--) { |
+ m.delete(i); |
+ assertEquals(i, m.size); |
+} |