summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/typedarray-constructor-mixed-bigint.js
blob: 20386fb515480c5c9231e97a7f69aa888767699d (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
// Copyright 2021 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.

let BigIntCtors = [BigInt64Array, BigUint64Array];
let NonBigIntCtors = [Int8Array,
                      Uint8Array,
                      Uint8ClampedArray,
                      Int16Array,
                      Uint16Array,
                      Int32Array,
                      Uint32Array,
                      Float32Array,
                      Float64Array];

function assertThrowsCannotMixBigInt(cb) {
  assertThrows(cb, TypeError, /Cannot mix BigInt/);
}

for (let bigIntTA of BigIntCtors) {
  for (let nonBigIntTA of NonBigIntCtors) {
    assertThrowsCannotMixBigInt(() => { new bigIntTA(new nonBigIntTA(0)); });
    assertThrowsCannotMixBigInt(() => { new bigIntTA(new nonBigIntTA(1)); });

    assertThrowsCannotMixBigInt(() => { new nonBigIntTA(new bigIntTA(0)); });
    assertThrowsCannotMixBigInt(() => { new nonBigIntTA(new bigIntTA(1)); });
  }
}