Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: test/mjsunit/wasm/export-table.js

Issue 2595733003: [wasm] Remove non-standard kExprI8Const bytecode (Closed)
Patch Set: Remove regression test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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() {
11 print("TestExportedMain..."); 11 print("TestExportedMain...");
12 var kReturnValue = 88; 12 var kReturnValue = 44;
13 var builder = new WasmModuleBuilder(); 13 var builder = new WasmModuleBuilder();
14 14
15 builder.addFunction("main", kSig_i_v) 15 builder.addFunction("main", kSig_i_v)
16 .addBody([ 16 .addBody([
17 kExprI8Const, 17 kExprI32Const,
18 kReturnValue, 18 kReturnValue,
19 kExprReturn 19 kExprReturn
20 ]) 20 ])
21 .exportFunc(); 21 .exportFunc();
22 22
23 var module = builder.instantiate(); 23 var module = builder.instantiate();
24 24
25 assertEquals("object", typeof module.exports); 25 assertEquals("object", typeof module.exports);
26 assertEquals("function", typeof module.exports.main); 26 assertEquals("function", typeof module.exports.main);
27 27
28 assertEquals(kReturnValue, module.exports.main()); 28 assertEquals(kReturnValue, module.exports.main());
29 })(); 29 })();
30 30
31 (function testExportedTwice() { 31 (function testExportedTwice() {
32 print("TestExportedTwice..."); 32 print("TestExportedTwice...");
33 var kReturnValue = 99; 33 var kReturnValue = 45;
34 34
35 var builder = new WasmModuleBuilder(); 35 var builder = new WasmModuleBuilder();
36 36
37 builder.addFunction("main", kSig_i_v) 37 builder.addFunction("main", kSig_i_v)
38 .addBody([ 38 .addBody([
39 kExprI8Const, 39 kExprI32Const,
40 kReturnValue, 40 kReturnValue,
41 kExprReturn 41 kExprReturn
42 ]) 42 ])
43 .exportAs("blah") 43 .exportAs("blah")
44 .exportAs("foo"); 44 .exportAs("foo");
45 45
46 var module = builder.instantiate(); 46 var module = builder.instantiate();
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() { 57 (function testEmptyName() {
58 print("TestEmptyName..."); 58 print("TestEmptyName...");
59 var kReturnValue = 93; 59 var kReturnValue = 46;
60 60
61 var builder = new WasmModuleBuilder(); 61 var builder = new WasmModuleBuilder();
62 62
63 builder.addFunction("main", kSig_i_v) 63 builder.addFunction("main", kSig_i_v)
64 .addBody([ 64 .addBody([
65 kExprI8Const, 65 kExprI32Const,
66 kReturnValue, 66 kReturnValue,
67 kExprReturn 67 kExprReturn
68 ]) 68 ])
69 .exportAs(""); 69 .exportAs("");
70 70
71 var module = builder.instantiate(); 71 var module = builder.instantiate();
72 72
73 assertEquals("object", typeof module.exports); 73 assertEquals("object", typeof module.exports);
74 assertEquals("function", typeof module.exports[""]); 74 assertEquals("function", typeof module.exports[""]);
75 75
76 assertEquals(kReturnValue, module.exports[""]()); 76 assertEquals(kReturnValue, module.exports[""]());
77 })(); 77 })();
78 78
79 (function testNumericName() { 79 (function testNumericName() {
80 print("TestNumericName..."); 80 print("TestNumericName...");
81 var kReturnValue = 93; 81 var kReturnValue = 47;
82 82
83 var builder = new WasmModuleBuilder(); 83 var builder = new WasmModuleBuilder();
84 84
85 builder.addFunction("main", kSig_i_v) 85 builder.addFunction("main", kSig_i_v)
86 .addBody([ 86 .addBody([
87 kExprI8Const, 87 kExprI32Const,
88 kReturnValue, 88 kReturnValue,
89 kExprReturn 89 kExprReturn
90 ]) 90 ])
91 .exportAs("0"); 91 .exportAs("0");
92 92
93 var module = builder.instantiate(); 93 var module = builder.instantiate();
94 94
95 assertEquals("object", typeof module.exports); 95 assertEquals("object", typeof module.exports);
96 assertEquals("function", typeof module.exports["0"]); 96 assertEquals("function", typeof module.exports["0"]);
97 97
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 builder.addExport("g", b); 167 builder.addExport("g", b);
168 168
169 let instance = builder.instantiate({q: {a: js, b: js}}); 169 let instance = builder.instantiate({q: {a: js, b: js}});
170 let e = instance.exports; 170 let e = instance.exports;
171 assertEquals("function", typeof e.f); 171 assertEquals("function", typeof e.f);
172 assertEquals("function", typeof e.g); 172 assertEquals("function", typeof e.g);
173 assertFalse(e.f == js); 173 assertFalse(e.f == js);
174 assertFalse(e.g == js); 174 assertFalse(e.g == js);
175 assertFalse(e.f == e.g); 175 assertFalse(e.f == e.g);
176 })(); 176 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698