summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/class/subclass/builtin-objects/Array/length.js
blob: e19bc322a66e3bad229a1b64700f0fffcdd2a10e (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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 22.1.4.1
description: >
  Instances has the own property length
info: |
  22.1.4.1 length

  The length property of an Array instance is a data property whose value is
  always numerically greater than the name of every configurable own property
  whose name is an array index.

  The length property initially has the attributes { [[Writable]]: true,
  [[Enumerable]]: false, [[Configurable]]: false }.
---*/

class Ar extends Array {}

var arr = new Ar('foo', 'bar');

assert.sameValue(arr[0], 'foo');
assert.sameValue(arr[1], 'bar');

var arrDesc = Object.getOwnPropertyDescriptor(arr, 'length');

assert.sameValue(arrDesc.writable, true);
assert.sameValue(arrDesc.enumerable, false);
assert.sameValue(arrDesc.configurable, false);

assert.sameValue(arr[1], 'bar');

arr.length = 1;

assert.sameValue(arr[0], 'foo');
assert.sameValue(arr[1], undefined);

reportCompare(0, 0);