summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/es6/typedarray-set-bytelength-not-smi.js
blob: e4a8c2b626352a46cc12616348995a942f60ee65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// 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 --mock-arraybuffer-allocator

(function TestBufferByteLengthNonSmi() {
  const source_buffer_length = %MaxSmi() + 1;
  const source_buffer = new ArrayBuffer(source_buffer_length);
  const source = new Uint16Array(source_buffer);
  assertEquals(source_buffer_length, source_buffer.byteLength);
  assertEquals(source_buffer_length / 2, source.length);

  const target_buffer_length = %MaxSmi() - 1;
  const target_buffer = new ArrayBuffer(target_buffer_length);
  const target = new Uint16Array(target_buffer);
  assertEquals(target_buffer_length, target_buffer.byteLength);
  assertEquals(target_buffer_length / 2, target.length);

  assertThrows(() => target.set(source), RangeError);
})();