summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/flat/null-undefined-elements.js
blob: 8bbf6a4ffae36d66c7f04873bd6b860214f6a9d9 (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
// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.flat
description: >
    arrays with null, and undefined
includes: [compareArray.js]
features: [Array.prototype.flat]
---*/

var a = [void 0];

assert.compareArray(
  [1, null, void 0].flat(),
  [1, null, undefined],
  '[1, null, void 0].flat() must return [1, null, undefined]'
);
assert.compareArray(
  [1, [null, void 0]].flat(),
  [1, null, undefined],
  '[1, [null, void 0]].flat() must return [1, null, undefined]'
);
assert.compareArray([
  [null, void 0],
  [null, void 0]
].flat(), [null, undefined, null, undefined], '[ [null, void 0], [null, void 0] ].flat() must return [null, undefined, null, undefined]');
assert.compareArray([1, [null, a]].flat(1), [1, null, a], '[1, [null, a]].flat(1) must return [1, null, a]');
assert.compareArray(
  [1, [null, a]].flat(2),
  [1, null, undefined],
  '[1, [null, a]].flat(2) must return [1, null, undefined]'
);

reportCompare(0, 0);