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: --expose-wasm --allow-natives-syntax |
| 6 |
| 7 load('test/mjsunit/wasm/wasm-constants.js'); |
| 8 load('test/mjsunit/wasm/wasm-module-builder.js'); |
| 9 |
| 10 let importingModuleBinary1 = (() => { |
| 11 var builder = new WasmModuleBuilder(); |
| 12 builder.addImport('', 'f', kSig_i_v); |
| 13 return new Int8Array(builder.toBuffer()); |
| 14 })(); |
| 15 |
| 16 let importingModuleBinary2 = (() => { |
| 17 var builder = new WasmModuleBuilder(); |
| 18 builder.addImport('', 'f', kSig_i_v); |
| 19 builder.addFunction('g', kSig_v_v) |
| 20 .addBody([kExprNop]); |
| 21 return new Int8Array(builder.toBuffer()); |
| 22 })(); |
| 23 |
| 24 let importingModuleBinary3 = (() => { |
| 25 var builder = new WasmModuleBuilder(); |
| 26 builder.addImport('', 'f', kSig_i_v); |
| 27 builder.addImport('', 'f2', kSig_i_v); |
| 28 builder.addFunction('g', kSig_v_v) |
| 29 .addBody([kExprNop]); |
| 30 return new Int8Array(builder.toBuffer()); |
| 31 })(); |
| 32 |
| 33 let importingModuleBinary4 = (() => { |
| 34 var builder = new WasmModuleBuilder(); |
| 35 builder.addFunction('g', kSig_v_v) |
| 36 .addBody([kExprNop]); |
| 37 return new Int8Array(builder.toBuffer()); |
| 38 })(); |
| 39 |
| 40 const complexImportingModuleBinary1 = (() => { |
| 41 let builder = new WasmModuleBuilder(); |
| 42 |
| 43 builder.addImport('a', 'b', kSig_v_v); |
| 44 builder.addImportedMemory('c', 'd', 1); |
| 45 builder.addImportedTable('e', 'f', 1); |
| 46 builder.addImportedGlobal('g', '⚡', kWasmI32); |
| 47 builder.addFunction('g', kSig_v_v) |
| 48 .addBody([kExprNop]); |
| 49 return builder.toBuffer(); |
| 50 })(); |
| 51 |
| 52 const complexImportingModuleBinary2 = (() => { |
| 53 let builder = new WasmModuleBuilder(); |
| 54 |
| 55 builder.addImport('a', 'b', kSig_v_v); |
| 56 builder.addImportedMemory('c', 'd', 1); |
| 57 builder.addImportedTable('e', 'f', 1); |
| 58 builder.addImportedGlobal('g', '⚡', kWasmI32); |
| 59 builder.addFunction('g', kSig_v_v) |
| 60 .addBody([kExprNop]); |
| 61 return builder.toBuffer(); |
| 62 })(); |
| 63 |
| 64 var tests = [ |
| 65 importingModuleBinary1, |
| 66 importingModuleBinary2, |
| 67 importingModuleBinary3, |
| 68 importingModuleBinary4, |
| 69 complexImportingModuleBinary1, |
| 70 complexImportingModuleBinary2 |
| 71 ]; |
| 72 |
| 73 for (var index in tests) { |
| 74 assertPromiseResult( |
| 75 WebAssembly.compile(tests[index]), |
| 76 m => assertTrue(m instanceof WebAssembly.Module), |
| 77 assertUnreachable); |
| 78 } |
OLD | NEW |