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

Unified Diff: test/mjsunit/wasm/export-table.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/divrem-trap.js ('k') | test/mjsunit/wasm/ffi.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/export-table.js
diff --git a/test/mjsunit/wasm/export-table.js b/test/mjsunit/wasm/export-table.js
index 0a0d406f475d4be2d74e27b52d84b1864d234fac..e85da9b6646ff63e927e5aa60a8c1b8076c26337 100644
--- a/test/mjsunit/wasm/export-table.js
+++ b/test/mjsunit/wasm/export-table.js
@@ -5,38 +5,20 @@
// Flags: --expose-wasm
load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
(function testExportedMain() {
- var kBodySize = 3;
- var kReturnValue = 99;
- var kNameMainOffset = kHeaderSize + 4 + 7 + kBodySize + 8 + 1;
+ var kReturnValue = 88;
+ var builder = new WasmModuleBuilder();
- var data = bytesWithHeader(
- // signatures
- kDeclSignatures, 1,
- 0, kAstI32, // void -> i32
- // -- main function
- kDeclFunctions,
- 1,
- 0, // decl flags
- 0, 0, // signature index
- kBodySize, 0,
- // main body
- kExprReturn,
- kExprI8Const,
- kReturnValue,
- // exports
- kDeclExportTable,
- 1,
- 0, 0, // func index index
- kNameMainOffset, 0, 0, 0, // function name offset
- // names
- kDeclEnd,
- 'm', 'a', 'i', 'n', 0 // --
- );
+ builder.addFunction("main", [kAstI32])
+ .addBody([
+ kExprReturn,
+ kExprI8Const,
+ kReturnValue])
+ .exportFunc();
- var ffi = new Object();
- var module = _WASMEXP_.instantiateModule(data, ffi);
+ var module = builder.instantiate();
assertEquals("object", typeof module.exports);
assertEquals("function", typeof module.exports.main);
@@ -45,45 +27,24 @@ load("test/mjsunit/wasm/wasm-constants.js");
})();
(function testExportedTwice() {
- var kBodySize = 3;
var kReturnValue = 99;
- var kNameMainOffset = kHeaderSize + 4 + 7 + kBodySize + 14 + 1;
- var kNameFooOffset = kNameMainOffset + 5;
- var data = bytesWithHeader(
- // signatures
- kDeclSignatures, 1,
- 0, kAstI32, // void -> i32
- // -- main function
- kDeclFunctions,
- 1,
- 0, // decl flags
- 0, 0, // signature index
- kBodySize, 0,
- // main body
- kExprReturn,
- kExprI8Const,
- kReturnValue,
- // exports
- kDeclExportTable,
- 2,
- 0, 0, // func index index
- kNameMainOffset, 0, 0, 0, // function name offset
- 0, 0, // func index index
- kNameFooOffset, 0, 0, 0, // function name offset
- // names
- kDeclEnd,
- 'b', 'l', 'a', 'h', 0, // --
- 'f', 'o', 'o', 0 // --
- );
+ var builder = new WasmModuleBuilder();
+
+ builder.addFunction("main", [kAstI32])
+ .addBody([
+ kExprReturn,
+ kExprI8Const,
+ kReturnValue])
+ .exportAs("blah")
+ .exportAs("foo");
- var ffi = new Object();
- var module = _WASMEXP_.instantiateModule(data, ffi);
+ var module = builder.instantiate();
assertEquals("object", typeof module.exports);
assertEquals("function", typeof module.exports.blah);
assertEquals("function", typeof module.exports.foo);
- assertEquals(kReturnValue, module.exports.blah());
assertEquals(kReturnValue, module.exports.foo());
+ assertEquals(kReturnValue, module.exports.blah());
})();
« no previous file with comments | « test/mjsunit/wasm/divrem-trap.js ('k') | test/mjsunit/wasm/ffi.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698