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

Unified Diff: test/mjsunit/asm/asm-validation.js

Issue 2648353010: [wasm][asm.js] Permit ternary operator in asm.js returns in some cases. (Closed)
Patch Set: fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/asmjs/test-asm-typer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/asm/asm-validation.js
diff --git a/test/mjsunit/asm/asm-validation.js b/test/mjsunit/asm/asm-validation.js
index 3dfd18caef29218516275517e793b70abad7ca0e..1f087fc01909827191d0bd23e7a63cbe6aa3f65a 100644
--- a/test/mjsunit/asm/asm-validation.js
+++ b/test/mjsunit/asm/asm-validation.js
@@ -413,3 +413,66 @@ function assertValidAsm(func) {
Module();
assertFalse(%IsAsmWasmCode(Module));
})();
+
+(function TestConditionalReturn() {
+ function Module() {
+ 'use asm';
+ function foo(a, b) {
+ a = +a;
+ b = +b;
+ // Allowed, despite not matching the spec, as emscripten emits this in
+ // practice.
+ return a == b ? +a : +b;
+ }
+ return foo;
+ }
+ var m = Module();
+ assertEquals(4, m(4, 4));
+ assertEquals(5, m(4, 5));
+ assertEquals(4, m(5, 4));
+ assertValidAsm(Module);
+})();
+
+(function TestMismatchedConditionalReturn() {
+ function Module() {
+ 'use asm';
+ function foo(a, b) {
+ a = +a;
+ return a == 0.0 ? 0 : +a;
+ }
+ return foo;
+ }
+ Module();
+ assertFalse(% IsAsmWasmCode(Module));
+})();
+
+(function TestBadIntConditionalReturn() {
+ function Module() {
+ 'use asm';
+ function foo(a, b) {
+ a = a | 0;
+ b = b | 0;
+ // Disallowed because signature must be signed, but these will be int.
+ return 1 ? a : b;
+ }
+ return foo;
+ }
+ Module();
+ assertFalse(% IsAsmWasmCode(Module));
+})();
+
+(function TestBadSignedConditionalReturn() {
+ function Module() {
+ 'use asm';
+ function foo(a, b) {
+ a = a | 0;
+ b = b | 0;
+ // Disallowed because conditional yields int, even when both sides
+ // are signed.
+ return 1 ? a | 0 : b | 0;
+ }
+ return foo;
+ }
+ Module();
+ assertFalse(% IsAsmWasmCode(Module));
+})();
« no previous file with comments | « test/cctest/asmjs/test-asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698