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

Unified Diff: test/mjsunit/wasm/stack.js

Issue 1770913002: [wasm] Use the JavaScript WasmModuleBuilder utility in JS tests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/wasm/params.js ('k') | test/mjsunit/wasm/stackwalk.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/stack.js
diff --git a/test/mjsunit/wasm/stack.js b/test/mjsunit/wasm/stack.js
index 379d3778ee91f00bce678d85967bc7e608fb9089..ed05517ae5070bb1361c5f23ef3c3618beed7114 100644
--- a/test/mjsunit/wasm/stack.js
+++ b/test/mjsunit/wasm/stack.js
@@ -5,44 +5,14 @@
// Flags: --expose-wasm
load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
-function testStack(func, check) {
- var kBodySize = 2;
- var kNameFunOffset = kHeaderSize + 22 + kBodySize + 1;
- var kNameMainOffset = kNameFunOffset + 4;
-
- var ffi = new Object();
- ffi.fun = func;
-
- var data = bytesWithHeader(
- // signatures
- kDeclSignatures, 1, // --
- 0, kAstStmt, // () -> void
- // -- foreign function
- kDeclFunctions, 2, // --
- kDeclFunctionName | kDeclFunctionImport, // --
- 0, 0, // --
- kNameFunOffset, 0, 0, 0, // name offset
- // -- main function
- kDeclFunctionName | kDeclFunctionExport, // --
- 0, 0, // --
- kNameMainOffset, 0, 0, 0, // name offset
- kBodySize, 0,
- // main body
- kExprCallFunction, 0, // --
- // names
- kDeclEnd, // --
- 'f', 'u', 'n', 0, // --
- 'm', 'a', 'i', 'n', 0 // --
- );
-
- var module = _WASMEXP_.instantiateModule(data, ffi);
-
- assertEquals("function", typeof module.main);
-
- module.main();
- check();
-}
+var expected = "Error\n" +
+ // The line numbers below will change as this test gains / loses lines..
+ " at STACK (stack.js:24:11)\n" + // --
+ " at <WASM> (<anonymous>)\n" + // TODO(jfb): wasm stack here.
+ " at testStack (stack.js:38:18)\n" + // --
+ " at stack.js:40:3"; // --
// The stack trace contains file path, only keep "stack.js".
function stripPath(s) {
@@ -55,16 +25,16 @@ function STACK() {
stack = e.stack;
}
-function check_STACK() {
- assertEquals(expected, stripPath(stack));
-}
+(function testStack() {
+ var builder = new WasmModuleBuilder();
-var expected = "Error\n" +
- // The line numbers below will change as this test gains / loses lines..
- " at STACK (stack.js:54:11)\n" + // --
- " at <WASM> (<anonymous>)\n" + // --
- " at testStack (stack.js:43:10)\n" +
- // TODO(jfb) Add WebAssembly stack here.
- " at stack.js:70:1";
+ builder.addImport("func", [kAstStmt]);
+
+ builder.addFunction(undefined, [kAstStmt])
+ .addBody([kExprCallImport, 0])
+ .exportAs("main");
-testStack(STACK, check_STACK);
+ var module = builder.instantiate({func: STACK});
+ module.exports.main();
+ assertEquals(expected, stripPath(stack));
+})();
« no previous file with comments | « test/mjsunit/wasm/params.js ('k') | test/mjsunit/wasm/stackwalk.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698