summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/flat/array-like-objects.js
blob: e89bbd22b8ffec6f4e77f51e570654d1284ec715 (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
// 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: >
    array-like objects can be flattened
includes: [compareArray.js]
features: [Array.prototype.flat]
---*/

function getArgumentsObject() {
  return arguments;
}

var a = getArgumentsObject([1], [2]);
var actual = [].flat.call(a);
assert.compareArray(actual, [1, 2], 'The value of actual is expected to be [1, 2]');

a = {
  length: 1,
  0: [1],
};
actual = [].flat.call(a);
assert.compareArray(actual, [1], 'The value of actual is expected to be [1]');

a = {
  length: undefined,
  0: [1],
};
actual = [].flat.call(a);
assert.compareArray(actual, [], 'The value of actual is expected to be []');

reportCompare(0, 0);