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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 ]) | 65 ]) |
66 .exportAs("0"); | 66 .exportAs("0"); |
67 | 67 |
68 var module = builder.instantiate(); | 68 var module = builder.instantiate(); |
69 | 69 |
70 assertEquals("object", typeof module.exports); | 70 assertEquals("object", typeof module.exports); |
71 assertEquals("function", typeof module.exports["0"]); | 71 assertEquals("function", typeof module.exports["0"]); |
72 | 72 |
73 assertEquals(kReturnValue, module.exports["0"]()); | 73 assertEquals(kReturnValue, module.exports["0"]()); |
74 })(); | 74 })(); |
75 | |
76 (function testExportNameClash() { | |
77 var builder = new WasmModuleBuilder(); | |
78 | |
79 builder.addFunction("one", kSig_v_v) | |
80 .addBody([kExprNop]) | |
81 .exportAs("main"); | |
82 | |
ahaas
2016/06/16 09:16:13
nit: Add an additional function in between to make
Clemens Hammacher
2016/06/16 12:16:10
Done.
| |
83 builder.addFunction("two", kSig_v_v) | |
84 .addBody([kExprNop]) | |
85 .exportAs("main"); | |
86 | |
87 try { | |
88 builder.instantiate(); | |
89 assertUnreachable("should have thrown an exception"); | |
90 } catch (e) { | |
91 assertContains("Duplicate export", e.toString()); | |
92 } | |
93 })(); | |
OLD | NEW |