Chromium Code Reviews| Index: test/mjsunit/harmony/collections.js |
| diff --git a/test/mjsunit/harmony/proxies-hash.js b/test/mjsunit/harmony/collections.js |
| similarity index 62% |
| copy from test/mjsunit/harmony/proxies-hash.js |
| copy to test/mjsunit/harmony/collections.js |
| index 2bf1830134d2b0f73ed6e25c68643190af2a3ae1..e400dafaacda79db69f24848b0e8dc6e7a0b0e23 100644 |
| --- a/test/mjsunit/harmony/proxies-hash.js |
| +++ b/test/mjsunit/harmony/collections.js |
| @@ -25,42 +25,39 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -// Flags: --harmony-proxies --harmony-weakmaps |
| +// Flags: --harmony-collections --expose-gc |
| -// Helper. |
| - |
| -function TestWithProxies(test, handler) { |
| - test(handler, Proxy.create) |
| - test(handler, function(h) {return Proxy.createFunction(h, function() {})}) |
| +// Test expected set behavior |
| +function TestSetBehavior(set, key) { |
| + assertFalse(set.has(key)); |
| + set.add(key); |
| + assertTrue(set.has(key)); |
| + set.delete(key); |
| + assertFalse(set.has(key)); |
| } |
| - |
| - |
| -// Weak maps. |
| - |
| -function TestWeakMap(fix) { |
| - TestWithProxies(TestWeakMap2, fix) |
| +function TestSet(set) { |
| + for (i = 0; i < 20; i++) { |
| + TestSetBehavior(set, new Object); |
| + } |
| } |
| - |
| -function TestWeakMap2(fix, create) { |
| - var handler = {fix: function() { return {} }} |
| - var p1 = create(handler) |
| - var p2 = create(handler) |
| - var p3 = create(handler) |
| - fix(p3) |
| - |
| - var m = new WeakMap |
| - m.set(p1, 123); |
| - m.set(p2, 321); |
| - assertSame(123, m.get(p1)); |
| - assertSame(321, m.get(p2)); |
| - |
| - fix(p1) |
| - fix(p2) |
| - assertSame(123, m.get(p1)); |
| - assertSame(321, m.get(p2)); |
| -} |
| - |
| -TestWeakMap(Object.seal) |
| -TestWeakMap(Object.freeze) |
| -TestWeakMap(Object.preventExtensions) |
| +TestSetBehavior(new Set, 23); |
| +TestSetBehavior(new Set, 'foo'); |
| +TestSet(new Set); |
| + |
| + |
| +//Test some common JavaScript idioms for Sets |
| +var s = new Set; |
| +assertTrue(s instanceof Set); |
| +assertTrue(Set.prototype.add instanceof Function) |
| +assertTrue(Set.prototype.has instanceof Function) |
| +assertTrue(Set.prototype.delete instanceof Function) |
| + |
| + |
| +// Test some common JavaScript idioms for Maps |
| +var m = new Map; |
| +assertTrue(m instanceof Map); |
| +assertTrue(Map.prototype.set instanceof Function) |
| +assertTrue(Map.prototype.get instanceof Function) |
| +assertTrue(Map.prototype.has instanceof Function) |
| +assertTrue(Map.prototype.delete instanceof Function) |
|
rossberg
2011/10/24 15:44:11
I don't see any proper test cases for maps (especi
Michael Starzinger
2011/10/25 11:17:26
Done.
|