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

Unified Diff: test/mjsunit/es6/map-set-minus-zero.js

Issue 947443005: Fix issue with -0 in Maps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/map-set-minus-zero.js
diff --git a/test/mjsunit/es6/map-set-minus-zero.js b/test/mjsunit/es6/map-set-minus-zero.js
new file mode 100644
index 0000000000000000000000000000000000000000..a12121effc6ceff6274c7291e7008bc96d7c5477
--- /dev/null
+++ b/test/mjsunit/es6/map-set-minus-zero.js
@@ -0,0 +1,52 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
adamk 2015/02/20 19:50:04 Nit: 2015
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+var t = new Map();
adamk 2015/02/20 19:50:04 Please add a Set codepath as well.
+
+var objectKey = {};
+var stringKey = 'keykeykey';
+var numberKey = 42.24;
+var booleanKey = true;
+var undefinedKey = undefined;
+var nullKey = null;
+var nanKey = NaN;
+var zeroKey = 0;
+var minusZeroKey = -0;
+
+
+assertEquals(t.size, 0);
adamk 2015/02/20 19:50:04 Please invert all the assertEquals() calls in this
+
+t.set(undefinedKey, 'value8');
+t.set(nullKey, 'value9');
+t.set(stringKey, 'value5');
+t.set(numberKey, 'value6');
+t.set(booleanKey, 'value7');
+t.set(objectKey, 'value1');
+t.set(nanKey, 'value10');
+t.set(zeroKey, 'value11');
+
+assertEquals(t.size, 8);
+
+assertEquals(t.get(objectKey), 'value1');
+assertEquals(t.get(stringKey), 'value5');
+assertEquals(t.get(numberKey), 'value6');
+assertEquals(t.get(booleanKey), 'value7');
+assertEquals(t.get(undefinedKey), 'value8');
+assertEquals(t.get(nullKey), 'value9');
+assertEquals(t.get(nanKey), 'value10');
+assertEquals(t.get(zeroKey), 'value11');
+
+assertEquals(t.get({}), undefined);
+assertEquals(t.get('keykeykey'), 'value5');
+assertEquals(t.get(42.24), 'value6');
+assertEquals(t.get(true), 'value7');
+assertEquals(t.get(undefined), 'value8');
+assertEquals(t.get(null), 'value9');
+assertEquals(t.get(NaN), 'value10');
+assertEquals(t.get(0), 'value11');
+assertEquals(t.get(-0), 'value11');
+assertEquals(t.get(1 / Infinity), 'value11');
+assertEquals(t.get(-1 / Infinity), 'value11');
« src/objects.cc ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698