OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 (function testExportedMain() { | 10 (function testExportedMain() { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 let instance = builder.instantiate(); | 127 let instance = builder.instantiate(); |
128 let e = instance.exports; | 128 let e = instance.exports; |
129 assertEquals("function", typeof e.a); | 129 assertEquals("function", typeof e.a); |
130 assertEquals("function", typeof e.b); | 130 assertEquals("function", typeof e.b); |
131 assertEquals("function", typeof e.c); | 131 assertEquals("function", typeof e.c); |
132 assertSame(e.a, e.b); | 132 assertSame(e.a, e.b); |
133 assertSame(e.a, e.c); | 133 assertSame(e.a, e.c); |
134 assertEquals(String(f.index), e.a.name); | 134 assertEquals(String(f.index), e.a.name); |
135 })(); | 135 })(); |
| 136 |
| 137 |
| 138 (function testReexportJSMultipleIdentity() { |
| 139 print("TestReexportMultipleIdentity..."); |
| 140 var builder = new WasmModuleBuilder(); |
| 141 |
| 142 function js() {} |
| 143 |
| 144 var a = builder.addImport("a", kSig_v_v); |
| 145 builder.addExport("f", a); |
| 146 builder.addExport("g", a); |
| 147 |
| 148 let instance = builder.instantiate({a: js}); |
| 149 let e = instance.exports; |
| 150 assertEquals("function", typeof e.f); |
| 151 assertEquals("function", typeof e.g); |
| 152 assertFalse(e.f == js); |
| 153 assertFalse(e.g == js); |
| 154 assertTrue(e.f == e.g); |
| 155 })(); |
| 156 |
| 157 |
| 158 (function testReexportJSMultiple() { |
| 159 print("TestReexportMultiple..."); |
| 160 var builder = new WasmModuleBuilder(); |
| 161 |
| 162 function js() {} |
| 163 |
| 164 var a = builder.addImport("a", kSig_v_v); |
| 165 var b = builder.addImport("b", kSig_v_v); |
| 166 builder.addExport("f", a); |
| 167 builder.addExport("g", b); |
| 168 |
| 169 let instance = builder.instantiate({a: js, b: js}); |
| 170 let e = instance.exports; |
| 171 assertEquals("function", typeof e.f); |
| 172 assertEquals("function", typeof e.g); |
| 173 assertFalse(e.f == js); |
| 174 assertFalse(e.g == js); |
| 175 assertFalse(e.f == e.g); |
| 176 })(); |
OLD | NEW |