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 // Flags: --wasm-jit-prototype |
6 | 7 |
7 load("test/mjsunit/wasm/wasm-constants.js"); | 8 load("test/mjsunit/wasm/wasm-constants.js"); |
8 load("test/mjsunit/wasm/wasm-module-builder.js"); | 9 load("test/mjsunit/wasm/wasm-module-builder.js"); |
9 | 10 |
10 var module = (function () { | 11 var module = (function () { |
11 var builder = new WasmModuleBuilder(); | 12 var builder = new WasmModuleBuilder(); |
12 | 13 |
13 var sig_index = builder.addSignature(kSig_i_ii); | 14 var sig_index = builder.addSignature(kSig_i_ii); |
14 builder.addImport("add", sig_index); | 15 builder.addImport("add", sig_index); |
15 builder.addFunction("add", sig_index) | 16 builder.addFunction("add", sig_index) |
(...skipping 19 matching lines...) Expand all Loading... |
35 return builder.instantiate({add: function(a, b) { return a + b | 0; }}); | 36 return builder.instantiate({add: function(a, b) { return a + b | 0; }}); |
36 })(); | 37 })(); |
37 | 38 |
38 // Check the module exists. | 39 // Check the module exists. |
39 assertFalse(module === undefined); | 40 assertFalse(module === undefined); |
40 assertFalse(module === null); | 41 assertFalse(module === null); |
41 assertFalse(module === 0); | 42 assertFalse(module === 0); |
42 assertEquals("object", typeof module.exports); | 43 assertEquals("object", typeof module.exports); |
43 assertEquals("function", typeof module.exports.main); | 44 assertEquals("function", typeof module.exports.main); |
44 | 45 |
45 assertEquals(5, module.exports.main(1, 12, 7)); | 46 // Check that the appropriate trap is generated |
46 assertEquals(19, module.exports.main(0, 12, 7)); | 47 assertTraps(kTrapFuncInvalid, "module.exports.main(-1,15,16)"); |
47 | 48 assertTraps(kTrapFuncInvalid, "module.exports.main(100000,15,16)"); |
48 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2, 12, 33)"); | 49 assertTraps(kTrapFuncInvalid, "module.exports.main(512,15,16)"); |
49 assertTraps(kTrapFuncInvalid, "module.exports.main(3, 12, 33)"); | 50 assertTraps(kTrapFuncInvalid, "module.exports.main(513,15,16)"); |
| 51 assertTraps(kTrapDefaultFuncCall, "module.exports.main(511,15,16)"); |
| 52 assertTraps(kTrapDefaultFuncCall, "module.exports.main(4,15,16)"); |
| 53 assertTraps(kTrapDefaultFuncCall, "module.exports.main(3,15,16)"); |
| 54 assertTraps(kTrapFuncSigMismatch, "module.exports.main(2,15,16)"); |
OLD | NEW |