summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Map/prototype/size/returns-count-of-present-values-before-after-set-clear.js
blob: 94316f9055e88bd1ba1445e92d90aa7285c2ffcd (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-get-map.prototype.size
description: >
  Returns count of present values before and after using `set` and `clear`.
info: |
  get Map.prototype.size

  5. Let count be 0.
  6. For each Record {[[key]], [[value]]} p that is an element of entries
    a. If p.[[key]] is not empty, set count to count+1.
---*/

var map = new Map();

assert.sameValue(map.size, 0, 'The value of `map.size` is `0`');

map.set(1, 1);
map.set(2, 2);
assert.sameValue(
  map.size, 2,
  'The value of `map.size` is `2`'
);

map.clear();
assert.sameValue(
  map.size, 0,
  'The value of `map.size` is `0`, after executing `map.clear()`'
);

reportCompare(0, 0);