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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 assertEquals("object", typeof module.exports); | 48 assertEquals("object", typeof module.exports); |
49 assertEquals("function", typeof module.exports.blah); | 49 assertEquals("function", typeof module.exports.blah); |
50 assertEquals("function", typeof module.exports.foo); | 50 assertEquals("function", typeof module.exports.foo); |
51 | 51 |
52 assertEquals(kReturnValue, module.exports.foo()); | 52 assertEquals(kReturnValue, module.exports.foo()); |
53 assertEquals(kReturnValue, module.exports.blah()); | 53 assertEquals(kReturnValue, module.exports.blah()); |
54 assertSame(module.exports.blah, module.exports.foo); | 54 assertSame(module.exports.blah, module.exports.foo); |
55 })(); | 55 })(); |
56 | 56 |
| 57 (function testEmptyName() { |
| 58 print("TestEmptyName..."); |
| 59 var kReturnValue = 93; |
| 60 |
| 61 var builder = new WasmModuleBuilder(); |
| 62 |
| 63 builder.addFunction("main", kSig_i_v) |
| 64 .addBody([ |
| 65 kExprI8Const, |
| 66 kReturnValue, |
| 67 kExprReturn |
| 68 ]) |
| 69 .exportAs(""); |
| 70 |
| 71 var module = builder.instantiate(); |
| 72 |
| 73 assertEquals("object", typeof module.exports); |
| 74 assertEquals("function", typeof module.exports[""]); |
| 75 |
| 76 assertEquals(kReturnValue, module.exports[""]()); |
| 77 })(); |
57 | 78 |
58 (function testNumericName() { | 79 (function testNumericName() { |
59 print("TestNumericName..."); | 80 print("TestNumericName..."); |
60 var kReturnValue = 93; | 81 var kReturnValue = 93; |
61 | 82 |
62 var builder = new WasmModuleBuilder(); | 83 var builder = new WasmModuleBuilder(); |
63 | 84 |
64 builder.addFunction("main", kSig_i_v) | 85 builder.addFunction("main", kSig_i_v) |
65 .addBody([ | 86 .addBody([ |
66 kExprI8Const, | 87 kExprI8Const, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 126 |
106 let instance = builder.instantiate(); | 127 let instance = builder.instantiate(); |
107 let e = instance.exports; | 128 let e = instance.exports; |
108 assertEquals("function", typeof e.a); | 129 assertEquals("function", typeof e.a); |
109 assertEquals("function", typeof e.b); | 130 assertEquals("function", typeof e.b); |
110 assertEquals("function", typeof e.c); | 131 assertEquals("function", typeof e.c); |
111 assertSame(e.a, e.b); | 132 assertSame(e.a, e.b); |
112 assertSame(e.a, e.c); | 133 assertSame(e.a, e.c); |
113 assertEquals(String(f.index), e.a.name); | 134 assertEquals(String(f.index), e.a.name); |
114 })(); | 135 })(); |
OLD | NEW |