| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 // Check the properties of the main function. | 45 // Check the properties of the main function. |
| 46 let main = instance.exports.main; | 46 let main = instance.exports.main; |
| 47 assertFalse(main === undefined); | 47 assertFalse(main === undefined); |
| 48 assertFalse(main === null); | 48 assertFalse(main === null); |
| 49 assertFalse(main === 0); | 49 assertFalse(main === 0); |
| 50 assertEquals("function", typeof main); | 50 assertEquals("function", typeof main); |
| 51 | 51 |
| 52 assertEquals(kReturnValue, main()); | 52 assertEquals(kReturnValue, main()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Deprecated experimental API. | |
| 56 CheckInstance(Wasm.instantiateModule(buffer)); | |
| 57 | |
| 58 // Official API | 55 // Official API |
| 59 let module = new WebAssembly.Module(buffer); | 56 let module = new WebAssembly.Module(buffer); |
| 60 CheckInstance(new WebAssembly.Instance(module)); | 57 CheckInstance(new WebAssembly.Instance(module)); |
| 61 | 58 |
| 62 let promise = WebAssembly.compile(buffer); | 59 let promise = WebAssembly.compile(buffer); |
| 63 promise.then(module => CheckInstance(new WebAssembly.Instance(module))); | 60 promise.then(module => CheckInstance(new WebAssembly.Instance(module))); |
| 64 | 61 |
| 65 // Check that validate works correctly for a module. | 62 // Check that validate works correctly for a module. |
| 66 assertTrue(WebAssembly.validate(buffer)); | 63 assertTrue(WebAssembly.validate(buffer)); |
| 67 assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); | 64 assertFalse(WebAssembly.validate(bytes(88, 88, 88, 88, 88, 88, 88, 88))); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 view_1[0] = 1; | 206 view_1[0] = 1; |
| 210 view_2[0] = 1000; | 207 view_2[0] = 1000; |
| 211 | 208 |
| 212 var module = new WebAssembly.Module(builder.toBuffer()); | 209 var module = new WebAssembly.Module(builder.toBuffer()); |
| 213 var i1 = new WebAssembly.Instance(module, null, mem_1); | 210 var i1 = new WebAssembly.Instance(module, null, mem_1); |
| 214 var i2 = new WebAssembly.Instance(module, null, mem_2); | 211 var i2 = new WebAssembly.Instance(module, null, mem_2); |
| 215 | 212 |
| 216 assertEquals(1, i1.exports.f()); | 213 assertEquals(1, i1.exports.f()); |
| 217 assertEquals(1000, i2.exports.f()); | 214 assertEquals(1000, i2.exports.f()); |
| 218 })(); | 215 })(); |
| OLD | NEW |