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 var kReturnValue = 117; | 10 var kReturnValue = 117; |
11 | 11 |
12 var module = (function Build() { | 12 var module = (function Build() { |
13 var builder = new WasmModuleBuilder(); | 13 var builder = new WasmModuleBuilder(); |
14 | 14 |
15 builder.addMemory(1, 1, true); | 15 builder.addMemory(1, 1, true); |
16 builder.addFunction("main", [kAstI32]) | 16 builder.addFunction("main", kSig_i) |
17 .addBody([kExprI8Const, kReturnValue]) | 17 .addBody([kExprI8Const, kReturnValue]) |
18 .exportFunc(); | 18 .exportFunc(); |
19 | 19 |
20 return builder.instantiate(); | 20 return builder.instantiate(); |
21 })(); | 21 })(); |
22 | 22 |
23 // Check the module exists. | 23 // Check the module exists. |
24 assertFalse(module === undefined); | 24 assertFalse(module === undefined); |
25 assertFalse(module === null); | 25 assertFalse(module === null); |
26 assertFalse(module === 0); | 26 assertFalse(module === 0); |
(...skipping 14 matching lines...) Expand all Loading... |
41 assertEquals(65536, module.exports.memory.byteLength); | 41 assertEquals(65536, module.exports.memory.byteLength); |
42 | 42 |
43 // Check the properties of the main function. | 43 // Check the properties of the main function. |
44 var main = module.exports.main; | 44 var main = module.exports.main; |
45 assertFalse(main === undefined); | 45 assertFalse(main === undefined); |
46 assertFalse(main === null); | 46 assertFalse(main === null); |
47 assertFalse(main === 0); | 47 assertFalse(main === 0); |
48 assertEquals("function", typeof main); | 48 assertEquals("function", typeof main); |
49 | 49 |
50 assertEquals(kReturnValue, main()); | 50 assertEquals(kReturnValue, main()); |
OLD | NEW |