12d8e6a54a
This removes the temporary option and sets its value to {true} everywhere. Bug: v8:7748 Change-Id: Icbc3071b531b130c0eb007758452d09b65491c04 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3974510 Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Reviewed-by: Matthias Liedtke <mliedtke@chromium.org> Cr-Commit-Position: refs/heads/main@{#83880}
105 lines
4.9 KiB
JavaScript
105 lines
4.9 KiB
JavaScript
// Copyright 2022 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: --experimental-wasm-gc --allow-natives-syntax
|
|
|
|
d8.file.execute('test/mjsunit/wasm/gc-js-interop-helpers.js');
|
|
|
|
let {struct, array} = CreateWasmObjects();
|
|
for (const wasm_obj of [struct, array]) {
|
|
|
|
// Test numeric operators.
|
|
testThrowsRepeated(() => ++wasm_obj, TypeError);
|
|
testThrowsRepeated(() => wasm_obj--, TypeError);
|
|
testThrowsRepeated(() => +wasm_obj, TypeError);
|
|
testThrowsRepeated(() => -wasm_obj, TypeError);
|
|
testThrowsRepeated(() => ~wasm_obj, TypeError);
|
|
testThrowsRepeated(() => wasm_obj - 2, TypeError);
|
|
testThrowsRepeated(() => wasm_obj * 2, TypeError);
|
|
testThrowsRepeated(() => wasm_obj / 2, TypeError);
|
|
testThrowsRepeated(() => wasm_obj ** 2, TypeError);
|
|
testThrowsRepeated(() => wasm_obj << 2, TypeError);
|
|
testThrowsRepeated(() => wasm_obj >> 2, TypeError);
|
|
testThrowsRepeated(() => 2 >>> wasm_obj, TypeError);
|
|
testThrowsRepeated(() => 2 % wasm_obj, TypeError);
|
|
testThrowsRepeated(() => wasm_obj | 1, TypeError);
|
|
testThrowsRepeated(() => 1 & wasm_obj, TypeError);
|
|
testThrowsRepeated(() => wasm_obj ^ wasm_obj, TypeError);
|
|
testThrowsRepeated(() => wasm_obj += 1, TypeError);
|
|
let tmp = 1;
|
|
testThrowsRepeated(() => tmp += wasm_obj, TypeError);
|
|
testThrowsRepeated(() => tmp <<= wasm_obj, TypeError);
|
|
testThrowsRepeated(() => tmp &= wasm_obj, TypeError);
|
|
testThrowsRepeated(() => tmp **= wasm_obj, TypeError);
|
|
|
|
// Test numeric functions of the global object.
|
|
testThrowsRepeated(() => isFinite(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => isNaN(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => parseFloat(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => parseInt(wasm_obj), TypeError);
|
|
|
|
// Test Number.
|
|
repeated(() => assertFalse(Number.isFinite(wasm_obj)));
|
|
repeated(() => assertFalse(Number.isInteger(wasm_obj)));
|
|
repeated(() => assertFalse(Number.isNaN(wasm_obj)));
|
|
repeated(() => assertFalse(Number.isSafeInteger(wasm_obj)));
|
|
testThrowsRepeated(() => Number.parseFloat(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Number.parseInt(wasm_obj), TypeError);
|
|
|
|
// Test BigInt.
|
|
testThrowsRepeated(() => BigInt.asIntN(2, wasm_obj), TypeError);
|
|
testThrowsRepeated(
|
|
() => BigInt.asUintN(wasm_obj, 123n), TypeError);
|
|
|
|
// Test Math.
|
|
testThrowsRepeated(() => Math.abs(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.acos(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.acosh(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.asin(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.asinh(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.atan(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.atanh(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.atan2(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.cbrt(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.ceil(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.clz32(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.cos(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.cosh(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.exp(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.expm1(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.floor(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.fround(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.hypot(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.imul(wasm_obj, wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.log(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.log1p(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.log10(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.log2(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.max(2, wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.min(2, wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.pow(2, wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.pow(wasm_obj, 2), TypeError);
|
|
testThrowsRepeated(() => Math.round(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.sign(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.sin(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.sinh(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.sqrt(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.tan(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.tanh(wasm_obj), TypeError);
|
|
testThrowsRepeated(() => Math.trunc(wasm_obj), TypeError);
|
|
|
|
// Test boolean.
|
|
repeated(() => assertFalse(!wasm_obj));
|
|
repeated(() => assertTrue(wasm_obj ? true : false));
|
|
tmp = true;
|
|
repeated(() => assertSame(wasm_obj, tmp &&= wasm_obj));
|
|
tmp = 0;
|
|
repeated(() => assertSame(wasm_obj, tmp ||= wasm_obj));
|
|
tmp = null;
|
|
repeated(() => assertSame(wasm_obj, tmp ??= wasm_obj));
|
|
|
|
// Ensure no statement re-assigned wasm_obj by accident.
|
|
assertTrue(wasm_obj == struct || wasm_obj == array);
|
|
}
|