summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Map/prototype/has/normalizes-zero-key.js
blob: 8bdc66d59cfe8a11e0feb0ceaeef4ee37bcd1805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-map.prototype.has
description: >
  -0 and +0 are normalized to +0;
info: |
  Map.prototype.has ( key )

  5. Repeat for each Record {[[key]], [[value]]} p that is an element of
  entries,
    a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true,
    return true.
  ...
---*/

var map = new Map();

assert.sameValue(map.has(-0), false);
assert.sameValue(map.has(+0), false);

map.set(-0, 42);
assert.sameValue(map.has(-0), true);
assert.sameValue(map.has(+0), true);

map.clear();

map.set(+0, 42);
assert.sameValue(map.has(-0), true);
assert.sameValue(map.has(+0), true);

reportCompare(0, 0);