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 = 117; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 51 |
52 // Deprecated experimental API. | 52 // Deprecated experimental API. |
53 CheckInstance(Wasm.instantiateModule(buffer)); | 53 CheckInstance(Wasm.instantiateModule(buffer)); |
54 | 54 |
55 // Official API | 55 // Official API |
56 let module = new WebAssembly.Module(buffer); | 56 let module = new WebAssembly.Module(buffer); |
57 CheckInstance(new WebAssembly.Instance(module)); | 57 CheckInstance(new WebAssembly.Instance(module)); |
58 | 58 |
59 let promise = WebAssembly.compile(buffer); | 59 let promise = WebAssembly.compile(buffer); |
60 promise.then(module => CheckInstance(new WebAssembly.Instance(module))); | 60 promise.then(module => CheckInstance(new WebAssembly.Instance(module))); |
61 | |
62 // Negative tests. | |
rossberg
2016/07/04 10:04:00
We should probably have a few new positive tests,
Mircea Trofin
2016/07/05 06:02:43
True - actually, for that to work, we'll have to c
| |
63 (function InvalidModules() { | |
64 let invalid_cases = [undefined, 1, "", "a", {some:1, obj: "b"}]; | |
65 let len = invalid_cases.length; | |
66 for (var i = 0; i < len; ++i) { | |
67 try { | |
68 let instance = new WebAssembly.Instance(1); | |
69 assertUnreachable("should not be able to instantiate invalid modules."); | |
70 } catch (e) { | |
71 assertContains("Argument 0", e.toString()); | |
72 } | |
73 } | |
74 })(); | |
OLD | NEW |