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

Side by Side Diff: test/mjsunit/wasm/js-api.js

Issue 2628053004: [wasm] JS-APIs: more WebAssembly.compile tests (Closed)
Patch Set: rebase 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
« no previous file with comments | « src/wasm/wasm-js.cc ('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 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 --allow-natives-syntax 5 // Flags: --expose-wasm --allow-natives-syntax
6 6
7 if ((typeof drainJobQueue) != "function") { 7 if ((typeof drainJobQueue) != "function") {
8 drainJobQueue = () => { %RunMicrotasks() }; 8 drainJobQueue = () => { %RunMicrotasks() };
9 } 9 }
10 10
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } catch (e) { 539 } catch (e) {
540 // TODO: error shouldn't be thrown, but should be globbed onto the promise. 540 // TODO: error shouldn't be thrown, but should be globbed onto the promise.
541 error = e; 541 error = e;
542 } 542 }
543 drainJobQueue(); 543 drainJobQueue();
544 assertEq(error instanceof err, true); 544 assertEq(error instanceof err, true);
545 assertEq(Boolean(error.stack.match("js-api.js")), true); 545 assertEq(Boolean(error.stack.match("js-api.js")), true);
546 //TODO assertEq(Boolean(error.message.match(msg)), true); 546 //TODO assertEq(Boolean(error.message.match(msg)), true);
547 } 547 }
548 assertCompileError([], TypeError, /requires more than 0 arguments/); 548 assertCompileError([], TypeError, /requires more than 0 arguments/);
549 //TODO assertCompileError([undefined], TypeError, /first argument must be an Arr ayBuffer or typed array object/); 549 assertCompileError([undefined], TypeError, /first argument must be an ArrayBuffe r or typed array object/);
550 //TODO assertCompileError([1], TypeError, /first argument must be an ArrayBuffer or typed array object/); 550 assertCompileError([1], TypeError, /first argument must be an ArrayBuffer or typ ed array object/);
551 //TODO assertCompileError([{}], TypeError, /first argument must be an ArrayBuffe r or typed array object/); 551 assertCompileError([{}], TypeError, /first argument must be an ArrayBuffer or ty ped array object/);
552 //TODO assertCompileError([new Uint8Array()], CompileError, /failed to match mag ic number/); 552 assertCompileError([new Uint8Array()], CompileError, /BufferSource argument is e mpty/);
553 //TODO assertCompileError([new ArrayBuffer()], CompileError, /failed to match ma gic number/); 553 assertCompileError([new ArrayBuffer()], CompileError, /BufferSource argument is empty/);
554 assertCompileError([new Uint8Array("hi!")], CompileError, /failed to match magic number/);
555 assertCompileError([new ArrayBuffer("hi!")], CompileError, /failed to match magi c number/);
556
554 function assertCompileSuccess(bytes) { 557 function assertCompileSuccess(bytes) {
555 var module = null; 558 var module = null;
556 compile(bytes).then(m => module = m); 559 compile(bytes).then(m => module = m);
557 drainJobQueue(); 560 drainJobQueue();
558 assertEq(module instanceof Module, true); 561 assertEq(module instanceof Module, true);
559 } 562 }
560 assertCompileSuccess(emptyModuleBinary); 563 assertCompileSuccess(emptyModuleBinary);
561 assertCompileSuccess(emptyModuleBinary.buffer); 564 assertCompileSuccess(emptyModuleBinary.buffer);
562 565
563 if (false) { // TODO: implement WebAssembly.instantiate 566 if (false) { // TODO: implement WebAssembly.instantiate
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 assertEq(result.instance instanceof Instance, true); 608 assertEq(result.instance instanceof Instance, true);
606 } 609 }
607 } 610 }
608 assertInstantiateSuccess(emptyModule); 611 assertInstantiateSuccess(emptyModule);
609 assertInstantiateSuccess(emptyModuleBinary); 612 assertInstantiateSuccess(emptyModuleBinary);
610 assertInstantiateSuccess(emptyModuleBinary.buffer); 613 assertInstantiateSuccess(emptyModuleBinary.buffer);
611 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); 614 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}});
612 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); 615 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}});
613 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); 616 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}});
614 } 617 }
OLDNEW
« no previous file with comments | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698