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

Side by Side Diff: test/mjsunit/wasm/globals.js

Issue 2584843002: Implement LinkError; import tweaks (Closed)
Patch Set: Created 4 years 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/export-table.js ('k') | test/mjsunit/wasm/import-table.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 TestImported(type, val, expected) { 10 function TestImported(type, val, expected) {
11 print("TestImported " + type + "(" + val +")" + " = " + expected); 11 print("TestImported " + type + "(" + val +")" + " = " + expected);
12 var builder = new WasmModuleBuilder(); 12 var builder = new WasmModuleBuilder();
13 var sig = makeSig([], [type]); 13 var sig = makeSig([], [type]);
14 var g = builder.addImportedGlobal("foo", undefined, type); 14 var g = builder.addImportedGlobal("foo", undefined, type);
15 builder.addFunction("main", sig) 15 builder.addFunction("main", sig)
16 .addBody([kExprGetGlobal, g.index]) 16 .addBody([kExprGetGlobal, g.index])
17 .exportAs("main"); 17 .exportAs("main");
18 builder.addGlobal(kAstI32); // pad 18 builder.addGlobal(kAstI32); // pad
19 19
20 var instance = builder.instantiate({foo: val}); 20 var instance = builder.instantiate({foo: val});
21 assertEquals(expected, instance.exports.main()); 21 assertEquals(expected, instance.exports.main());
22 } 22 }
23 23
24 TestImported(kAstI32, 300.1, 300); 24 TestImported(kAstI32, 300.1, 300);
25 TestImported(kAstF32, 87234.87238, Math.fround(87234.87238)); 25 TestImported(kAstF32, 87234.87238, Math.fround(87234.87238));
26 TestImported(kAstF64, 77777.88888, 77777.88888); 26 TestImported(kAstF64, 77777.88888, 77777.88888);
27 TestImported(kAstF64, "89", 89);
28 27
29 28
30 function TestExported(type, val, expected) { 29 function TestExported(type, val, expected) {
31 print("TestExported " + type + "(" + val +")" + " = " + expected); 30 print("TestExported " + type + "(" + val +")" + " = " + expected);
32 var builder = new WasmModuleBuilder(); 31 var builder = new WasmModuleBuilder();
33 var sig = makeSig([type], []); 32 var sig = makeSig([type], []);
34 builder.addGlobal(kAstI32); // pad 33 builder.addGlobal(kAstI32); // pad
35 var g = builder.addGlobal(type, false) 34 var g = builder.addGlobal(type, false)
36 .exportAs("foo"); 35 .exportAs("foo");
37 g.init = val; 36 g.init = val;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 .addBody([kExprGetGlobal, def.index]) 78 .addBody([kExprGetGlobal, def.index])
80 .exportAs("main"); 79 .exportAs("main");
81 80
82 var instance = builder.instantiate({foo: val}); 81 var instance = builder.instantiate({foo: val});
83 assertEquals(val, instance.exports.main()); 82 assertEquals(val, instance.exports.main());
84 } 83 }
85 84
86 TestGlobalIndexSpace(kAstI32, 123); 85 TestGlobalIndexSpace(kAstI32, 123);
87 TestGlobalIndexSpace(kAstF32, 54321.125); 86 TestGlobalIndexSpace(kAstF32, 54321.125);
88 TestGlobalIndexSpace(kAstF64, 12345.678); 87 TestGlobalIndexSpace(kAstF64, 12345.678);
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/export-table.js ('k') | test/mjsunit/wasm/import-table.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698