2e197ba64e
This change implements the WebAssembly.Global object and constructor, but none of the accessors or functions. There is a new flag to enable this: --experimental-wasm-mut-global. Change-Id: Ifeb270d57392d7ca0900c80c0038932c96ee8b61 Reviewed-on: https://chromium-review.googlesource.com/989296 Commit-Queue: Ben Smith <binji@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#52335}
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
// Copyright 2018 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-mut-global
|
|
|
|
function assertGlobalIsValid(global) {
|
|
assertSame(WebAssembly.Global.prototype, global.__proto__);
|
|
assertSame(WebAssembly.Global, global.constructor);
|
|
assertTrue(global instanceof Object);
|
|
assertTrue(global instanceof WebAssembly.Global);
|
|
}
|
|
|
|
(function TestConstructor() {
|
|
|
|
assertTrue(WebAssembly.Global instanceof Function);
|
|
assertSame(WebAssembly.Global, WebAssembly.Global.prototype.constructor);
|
|
|
|
assertThrows(() => new WebAssembly.Global(), TypeError);
|
|
assertThrows(() => new WebAssembly.Global(1), TypeError);
|
|
assertThrows(() => new WebAssembly.Global(""), TypeError);
|
|
|
|
assertThrows(() => new WebAssembly.Global({}), TypeError);
|
|
assertThrows(() => new WebAssembly.Global({type: 'foo'}), TypeError);
|
|
assertThrows(() => new WebAssembly.Global({type: 'i64'}), TypeError);
|
|
|
|
for (let type of ['i32', 'f32', 'f64']) {
|
|
assertGlobalIsValid(new WebAssembly.Global({type}));
|
|
}
|
|
})();
|