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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } catch (e) { | 91 } catch (e) { |
92 assertContains("Duplicate export", e.toString()); | 92 assertContains("Duplicate export", e.toString()); |
93 } | 93 } |
94 })(); | 94 })(); |
95 | 95 |
96 | 96 |
97 (function testExportMultipleIdentity() { | 97 (function testExportMultipleIdentity() { |
98 print("TestExportMultipleIdentity..."); | 98 print("TestExportMultipleIdentity..."); |
99 var builder = new WasmModuleBuilder(); | 99 var builder = new WasmModuleBuilder(); |
100 | 100 |
101 builder.addFunction("one", kSig_v_v).addBody([kExprNop]) | 101 var f = builder.addFunction("one", kSig_v_v).addBody([kExprNop]) |
102 .exportAs("a") | 102 .exportAs("a") |
103 .exportAs("b") | 103 .exportAs("b") |
104 .exportAs("c"); | 104 .exportAs("c"); |
105 | 105 |
106 let instance = builder.instantiate(); | 106 let instance = builder.instantiate(); |
107 let e = instance.exports; | 107 let e = instance.exports; |
108 assertEquals("function", typeof e.a); | 108 assertEquals("function", typeof e.a); |
109 assertEquals("function", typeof e.b); | 109 assertEquals("function", typeof e.b); |
110 assertEquals("function", typeof e.c); | 110 assertEquals("function", typeof e.c); |
111 assertSame(e.a, e.b); | 111 assertSame(e.a, e.b); |
112 assertSame(e.a, e.c); | 112 assertSame(e.a, e.c); |
113 assertEquals("a", e.a.name); | 113 assertEquals(String(f.index), e.a.name); |
114 })(); | 114 })(); |
OLD | NEW |