Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: test/mjsunit/es6/collections.js

Issue 478683002: ES6: Make sure we do not store -0 as the key in Map/Set (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/collections.js
diff --git a/test/mjsunit/es6/collections.js b/test/mjsunit/es6/collections.js
index 911b748ed9de632d7da903f203d744fea2cfaa44..940c0b9d1fab8a314b071e9d5cd6d50fab4cd41d 100644
--- a/test/mjsunit/es6/collections.js
+++ b/test/mjsunit/es6/collections.js
@@ -117,7 +117,8 @@ function TestMapBehavior2(m) {
TestMapping(m, i / 10, new Object);
TestMapping(m, 'key-' + i, new Object);
}
- var keys = [ +0, -0, +Infinity, -Infinity, true, false, null, undefined ];
+ // -0 is handled in TestMinusZeroMap
+ var keys = [ 0, +Infinity, -Infinity, true, false, null, undefined ];
for (var i = 0; i < keys.length; i++) {
TestMapping(m, keys[i], new Object);
}
@@ -495,24 +496,26 @@ for (var i = 9; i >= 0; i--) {
(function TestMinusZeroSet() {
- var m = new Set();
- m.add(0);
- m.add(-0);
- assertEquals(1, m.size);
- assertTrue(m.has(0));
- assertTrue(m.has(-0));
+ var s = new Set();
+ s.add(-0);
+ assertSame(0, s.values().next().value);
+ s.add(0);
+ assertEquals(1, s.size);
+ assertTrue(s.has(0));
+ assertTrue(s.has(-0));
})();
(function TestMinusZeroMap() {
var m = new Map();
- m.set(0, 'plus');
m.set(-0, 'minus');
+ assertSame(0, m.keys().next().value);
+ m.set(0, 'plus');
assertEquals(1, m.size);
assertTrue(m.has(0));
assertTrue(m.has(-0));
- assertEquals('minus', m.get(0));
- assertEquals('minus', m.get(-0));
+ assertEquals('plus', m.get(0));
+ assertEquals('plus', m.get(-0));
})();
« no previous file with comments | « src/collection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698