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

Unified Diff: test/mjsunit/wasm/function-prototype.js

Issue 1778863002: [wasm] Create a proper map for functions created from WASM. (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 | « src/wasm/wasm-js.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/function-prototype.js
diff --git a/test/mjsunit/wasm/function-prototype.js b/test/mjsunit/wasm/function-prototype.js
new file mode 100644
index 0000000000000000000000000000000000000000..db04b950bba5e7ebf028f7cc49c55356099ac48c
--- /dev/null
+++ b/test/mjsunit/wasm/function-prototype.js
@@ -0,0 +1,35 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --expose-wasm
+
+load("test/mjsunit/wasm/wasm-constants.js");
+load("test/mjsunit/wasm/wasm-module-builder.js");
+
+(function TestFunctionPrototype() {
+ var builder = new WasmModuleBuilder();
+
+ builder.addFunction("nine", [kAstI32])
+ .addBody([kExprI8Const, 9])
+ .exportFunc();
+
+ var func = builder.instantiate().exports.nine;
+
+ // Check type and existence of prototype
+ assertEquals("function", typeof func.apply);
+ assertTrue(func.prototype != undefined);
+ assertEquals("nine", func.name);
+ assertEquals(undefined, func.displayName);
+
+ // Check that .apply() works.
+ assertEquals(9, func.apply([]));
+ assertEquals(9, func.apply([1]));
+ assertEquals(9, func.apply([2, 3]));
+ assertEquals(9, func.apply([6, 7, 9, 9]));
+
+ // TODO(titzer): assertEquals(1, func.length);
+
+ // Check we don't crash when converting to a string.
+ print(func.toString());
+})();
« 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