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

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

Issue 2552123004: [wasm] Fix ToNumber conversion (Closed)
Patch Set: Minor fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | test/mjsunit/wasm/ffi-error.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/ffi.js
diff --git a/test/mjsunit/wasm/ffi.js b/test/mjsunit/wasm/ffi.js
index 58253061055d2dad1e8d5b4b06e07926bbf8d478..959c659d4e5ade8e364d26014e7a5f438e2b58bb 100644
--- a/test/mjsunit/wasm/ffi.js
+++ b/test/mjsunit/wasm/ffi.js
@@ -338,3 +338,50 @@ testCallBinopVoid(kAstF64);
'-3': {18: print}
});
})();
+
+(function ImportSymbolAsVoidDoesNotThrow() {
+ var builder = new WasmModuleBuilder();
+ // Return type is void, so there should be no ToNumber conversion.
+ var index = builder.addImport("func", kSig_v_v);
+ builder.addFunction("main", kSig_v_v)
+ .addBody([kExprCallFunction, 0])
+ .exportFunc();
+ var func = () => Symbol();
+ var main = builder.instantiate({func: func}).exports.main;
+ main();
+})();
+
+(function ToNumberCalledOnImport() {
+ var builder = new WasmModuleBuilder();
+ // Return type is int, so there should be a ToNumber conversion.
+ var index = builder.addImport("func", kSig_i_v);
+ builder.addFunction("main", kSig_i_v)
+ .addBody([kExprCallFunction, 0])
+ .exportFunc();
+ var num_valueOf = 0;
+ function Foo() {}
+ Foo.prototype.valueOf = () => ++num_valueOf;
+ var func = () => new Foo();
+ var main = builder.instantiate({func: func}).exports.main;
+ main();
+ assertEquals(1, num_valueOf);
+ main();
+ assertEquals(2, num_valueOf);
+})();
+
+(function ToNumberNotCalledOnVoidImport() {
+ var builder = new WasmModuleBuilder();
+ // Return type is void, so there should be no ToNumber conversion.
+ var index = builder.addImport("func", kSig_v_v);
+ builder.addFunction("main", kSig_v_v)
+ .addBody([kExprCallFunction, 0])
+ .exportFunc();
+ var num_valueOf = 0;
+ function Foo() {}
+ Foo.prototype.valueOf = () => ++num_valueOf;
+ var func = () => new Foo();
+ var main = builder.instantiate({func: func}).exports.main;
+ main();
+ main();
+ assertEquals(0, num_valueOf);
+})();
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | test/mjsunit/wasm/ffi-error.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698