aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6/typedarray-construct-by-array-like-prototype-element-added.js
blob: edcba43b527e1cecc306698a36d49e4129497d22 (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 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --allow-natives-syntax

(function() {
  var arr = [0, 1, , 3];
  Array.prototype[2] = 2;

  var constructors = [
    Uint8Array,
    Int8Array,
    Uint16Array,
    Int16Array,
    Uint32Array,
    Int32Array,
    Float32Array,
    Float64Array,
    Uint8ClampedArray
  ];

  for (var constr of constructors) {
    var ta = new constr(arr);
    assertArrayEquals([0, 1, 2, 3], ta);
  }
})();

(function testTypedArrayConstructByArrayLikeInvalidArrayProtector() {
  Array.prototype[2] = undefined;
  load("test/mjsunit/es6/typedarray-construct-by-array-like.js");
})();