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

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

Issue 2361053004: Revert of [wasm] Master CL for Binary 0xC changes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « test/mjsunit/wasm/exceptions.js ('k') | test/mjsunit/wasm/ffi.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 var kReturnValue = 88; 11 var kReturnValue = 88;
12 var builder = new WasmModuleBuilder(); 12 var builder = new WasmModuleBuilder();
13 13
14 builder.addFunction("main", kSig_i) 14 builder.addFunction("main", kSig_i)
15 .addBody([ 15 .addBody([
16 kExprI8Const, 16 kExprI8Const,
17 kReturnValue, 17 kReturnValue,
18 kExprReturn 18 kExprReturn, kArity1
19 ]) 19 ])
20 .exportFunc(); 20 .exportFunc();
21 21
22 var module = builder.instantiate(); 22 var module = builder.instantiate();
23 23
24 assertEquals("object", typeof module.exports); 24 assertEquals("object", typeof module.exports);
25 assertEquals("function", typeof module.exports.main); 25 assertEquals("function", typeof module.exports.main);
26 26
27 assertEquals(kReturnValue, module.exports.main()); 27 assertEquals(kReturnValue, module.exports.main());
28 })(); 28 })();
29 29
30 (function testExportedTwice() { 30 (function testExportedTwice() {
31 var kReturnValue = 99; 31 var kReturnValue = 99;
32 32
33 var builder = new WasmModuleBuilder(); 33 var builder = new WasmModuleBuilder();
34 34
35 builder.addFunction("main", kSig_i) 35 builder.addFunction("main", kSig_i)
36 .addBody([ 36 .addBody([
37 kExprI8Const, 37 kExprI8Const,
38 kReturnValue, 38 kReturnValue,
39 kExprReturn 39 kExprReturn, kArity1
40 ]) 40 ])
41 .exportAs("blah") 41 .exportAs("blah")
42 .exportAs("foo"); 42 .exportAs("foo");
43 43
44 var module = builder.instantiate(); 44 var module = builder.instantiate();
45 45
46 assertEquals("object", typeof module.exports); 46 assertEquals("object", typeof module.exports);
47 assertEquals("function", typeof module.exports.blah); 47 assertEquals("function", typeof module.exports.blah);
48 assertEquals("function", typeof module.exports.foo); 48 assertEquals("function", typeof module.exports.foo);
49 49
50 assertEquals(kReturnValue, module.exports.foo()); 50 assertEquals(kReturnValue, module.exports.foo());
51 assertEquals(kReturnValue, module.exports.blah()); 51 assertEquals(kReturnValue, module.exports.blah());
52 })(); 52 })();
53 53
54 54
55 (function testNumericName() { 55 (function testNumericName() {
56 var kReturnValue = 93; 56 var kReturnValue = 93;
57 57
58 var builder = new WasmModuleBuilder(); 58 var builder = new WasmModuleBuilder();
59 59
60 builder.addFunction("main", kSig_i) 60 builder.addFunction("main", kSig_i)
61 .addBody([ 61 .addBody([
62 kExprI8Const, 62 kExprI8Const,
63 kReturnValue, 63 kReturnValue,
64 kExprReturn 64 kExprReturn, kArity1
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 75
76 (function testExportNameClash() { 76 (function testExportNameClash() {
77 var builder = new WasmModuleBuilder(); 77 var builder = new WasmModuleBuilder();
78 78
79 builder.addFunction("one", kSig_v_v).addBody([kExprNop]).exportAs("main"); 79 builder.addFunction("one", kSig_v_v).addBody([kExprNop]).exportAs("main");
80 builder.addFunction("two", kSig_v_v).addBody([kExprNop]).exportAs("other"); 80 builder.addFunction("two", kSig_v_v).addBody([kExprNop]).exportAs("other");
81 builder.addFunction("three", kSig_v_v).addBody([kExprNop]).exportAs("main"); 81 builder.addFunction("three", kSig_v_v).addBody([kExprNop]).exportAs("main");
82 82
83 try { 83 try {
84 builder.instantiate(); 84 builder.instantiate();
85 assertUnreachable("should have thrown an exception"); 85 assertUnreachable("should have thrown an exception");
86 } catch (e) { 86 } catch (e) {
87 assertContains("Duplicate export", e.toString()); 87 assertContains("Duplicate export", e.toString());
88 } 88 }
89 })(); 89 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/exceptions.js ('k') | test/mjsunit/wasm/ffi.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698