OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 7 load("test/mjsunit/wasm/wasm-constants.js"); |
8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 8 load("test/mjsunit/wasm/wasm-module-builder.js"); |
9 | 9 |
10 let kReturnValue = 117; | 10 let kReturnValue = 17; |
11 | 11 |
12 let buffer = (() => { | 12 let buffer = (() => { |
13 let builder = new WasmModuleBuilder(); | 13 let builder = new WasmModuleBuilder(); |
14 builder.addMemory(1, 1, true); | 14 builder.addMemory(1, 1, true); |
15 builder.addFunction("main", kSig_i_v) | 15 builder.addFunction("main", kSig_i_v) |
16 .addBody([kExprI8Const, kReturnValue]) | 16 .addBody([kExprI32Const, kReturnValue]) |
17 .exportFunc(); | 17 .exportFunc(); |
18 | 18 |
19 return builder.toBuffer(); | 19 return builder.toBuffer(); |
20 })() | 20 })() |
21 | 21 |
22 function CheckInstance(instance) { | 22 function CheckInstance(instance) { |
23 assertFalse(instance === undefined); | 23 assertFalse(instance === undefined); |
24 assertFalse(instance === null); | 24 assertFalse(instance === null); |
25 assertFalse(instance === 0); | 25 assertFalse(instance === 0); |
26 assertEquals("object", typeof instance); | 26 assertEquals("object", typeof instance); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 assertEquals(1, i1.exports.f()); | 219 assertEquals(1, i1.exports.f()); |
220 assertEquals(1000, i2.exports.f()); | 220 assertEquals(1000, i2.exports.f()); |
221 })(); | 221 })(); |
222 | 222 |
223 (function MustBeMemory() { | 223 (function MustBeMemory() { |
224 print("MustBeMemory..."); | 224 print("MustBeMemory..."); |
225 var memory = new ArrayBuffer(65536); | 225 var memory = new ArrayBuffer(65536); |
226 var module = new WebAssembly.Module(buffer); | 226 var module = new WebAssembly.Module(buffer); |
227 assertThrows(() => new WebAssembly.Instance(module, null, memory), TypeError); | 227 assertThrows(() => new WebAssembly.Instance(module, null, memory), TypeError); |
228 })(); | 228 })(); |
OLD | NEW |