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

Side by Side Diff: test/mjsunit/wasm/import-table.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/globals.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 testCallImport(func, check) { 10 function testCallImport(func, check) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 kExprI8Const, 97, // -- 248 kExprI8Const, 97, // --
249 kExprCallFunction, 0, // -- 249 kExprCallFunction, 0, // --
250 kExprGetLocal, 0, // -- 250 kExprGetLocal, 0, // --
251 kExprCallFunction, 1 // -- 251 kExprCallFunction, 1 // --
252 ]) 252 ])
253 .exportFunc(); 253 .exportFunc();
254 254
255 var main = builder.instantiate({print: print}).exports.main; 255 var main = builder.instantiate({print: print}).exports.main;
256 256
257 for (var i = -9; i < 900; i += 16.125) { 257 for (var i = -9; i < 900; i += 16.125) {
258 main(i); 258 main(i);
259 } 259 }
260 } 260 }
261 261
262 testCallPrint(); 262 testCallPrint();
263 testCallPrint(); 263 testCallPrint();
264 264
265 265
266 function testCallImport2(foo, bar, expected) { 266 function testCallImport2(foo, bar, expected) {
267 var builder = new WasmModuleBuilder(); 267 var builder = new WasmModuleBuilder();
268 268
269 builder.addImport("foo", kSig_i_v); 269 builder.addImport("foo", kSig_i_v);
270 builder.addImport("bar", kSig_i_v); 270 builder.addImport("bar", kSig_i_v);
271 builder.addFunction("main", kSig_i_v) 271 builder.addFunction("main", kSig_i_v)
272 .addBody([ 272 .addBody([
273 kExprCallFunction, 0, // -- 273 kExprCallFunction, 0, // --
274 kExprCallFunction, 1, // -- 274 kExprCallFunction, 1, // --
275 kExprI32Add, // -- 275 kExprI32Add, // --
276 ]) // -- 276 ]) // --
277 .exportFunc(); 277 .exportFunc();
278 278
279 var main = builder.instantiate({foo: foo, bar: bar}).exports.main; 279 var main = builder.instantiate({foo: foo, bar: bar}).exports.main;
280 assertEquals(expected, main()); 280 assertEquals(expected, main());
281 } 281 }
282 282
283 testCallImport2(function() { return 33; }, function () { return 44; }, 77); 283 testCallImport2(function() { return 33; }, function () { return 44; }, 77);
284
285
286 function testImportName(name) {
287 var builder = new WasmModuleBuilder();
288 builder.addImportWithModule("M", name, kSig_i_v);
289 builder.addFunction("main", kSig_i_v)
290 .addBody([
291 kExprCallFunction, 0
292 ])
293 .exportFunc();
294
295 let main = builder.instantiate({M: {[name]: () => 42}}).exports.main;
296 assertEquals(42, main());
297 }
298
299 testImportName("bla");
300 testImportName("0");
301 testImportName(" a @#$2 324 ");
302 // TODO(bradnelson): This should succeed.
303 // testImportName("");
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/globals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698