summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/WeakMap/prototype/get/returns-undefined-if-key-cannot-be-held-weakly.js
blob: b05b51b67a713f6d210d21af0f09fc0899107647 (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
33
34
35
36
37
38
39
// 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-weakmap.prototype.get
description: >
  Returns undefined when key cannot be held weakly.
info: |
  WeakMap.prototype.get ( _key_ )
  4. If CanBeHeldWeakly(_key_) is *false*, return *undefined*.
features: [Symbol, WeakMap]
---*/

var map = new WeakMap();

assert.sameValue(map.get(null), undefined, 'Returns undefined if key is null');

assert.sameValue(map.get(NaN), undefined, 'Returns undefined if key is NaN');

assert.sameValue(
  map.get('foo'), undefined,
  'Returns undefined if key is a String'
);

assert.sameValue(
  map.get(1), undefined,
  'Returns undefined if key is a Number'
);

assert.sameValue(
  map.get(undefined), undefined,
  'Returns undefined if key is undefined'
);

assert.sameValue(
  map.get(Symbol.for('registered symbol')), undefined,
  'Returns undefined if key is a registered Symbol'
);

reportCompare(0, 0);