OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --allow-natives-syntax |
| 6 |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 9 |
| 10 %ResetWasmOverloads(); |
| 11 let buffer = (() => { |
| 12 let builder = new WasmModuleBuilder(); |
| 13 builder.addFunction("f", kSig_i_v) |
| 14 .addBody([kExprI32Const, 42]) |
| 15 .exportAs("f"); |
| 16 return builder.toBuffer(); |
| 17 })(); |
| 18 |
| 19 var module = new WebAssembly.Module(buffer); |
| 20 var wrapper = [module]; |
| 21 |
| 22 assertPromiseResult( |
| 23 WebAssembly.instantiate(wrapper), |
| 24 assertUnreachable, |
| 25 e => assertTrue(e instanceof TypeError)); |
| 26 |
| 27 assertPromiseResult( |
| 28 (() => { |
| 29 %SetWasmCompileFromPromiseOverload(); |
| 30 return WebAssembly.instantiate(wrapper); |
| 31 })(), |
| 32 pair => { |
| 33 print(2); |
| 34 var pair = result.pair; |
| 35 assertTrue(pair.instance instanceof WebAssembly.Instance); |
| 36 assertTrue(pair.module instanceof WebAssembly.Module); |
| 37 %ResetWasmOverloads(); |
| 38 }, |
| 39 assertUnreachable); |
OLD | NEW |