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

Side by Side Diff: test/mjsunit/asm/asm-validation.js

Issue 2565343002: [wasm][asm.js] Require a number for fround literals. (Closed)
Patch Set: git cl try 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 unified diff | Download patch
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --validate-asm --allow-natives-syntax 5 // Flags: --validate-asm --allow-natives-syntax
6 6
7 // Note that this test file contains tests that explicitly check modules are 7 // Note that this test file contains tests that explicitly check modules are
8 // valid asm.js and then break them with invalid instantiation arguments. If 8 // valid asm.js and then break them with invalid instantiation arguments. If
9 // this script is run more than once (e.g. --stress-opt) then modules remain 9 // this script is run more than once (e.g. --stress-opt) then modules remain
10 // broken in the second run and assertions would fail. We prevent re-runs. 10 // broken in the second run and assertions would fail. We prevent re-runs.
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 337 }
338 return { foo: foo }; 338 return { foo: foo };
339 } 339 }
340 var m = Module(); 340 var m = Module();
341 // We all false here because the parser optimizes expressons like: 341 // We all false here because the parser optimizes expressons like:
342 // !123 to false. 342 // !123 to false.
343 assertTrue(%IsAsmWasmCode(Module)); 343 assertTrue(%IsAsmWasmCode(Module));
344 assertEquals(4, m.foo(3)); 344 assertEquals(4, m.foo(3));
345 })(); 345 })();
346 346
347 (function TestBadFroundTrue() {
348 function Module(stdlib) {
349 "use asm";
350 var fround = stdlib.Math.fround;
351 function foo() {
352 var x = fround(true);
353 return +x;
354 }
355 return { foo: foo };
356 }
357 var m = Module(this);
358 assertFalse(%IsAsmWasmCode(Module));
359 assertEquals(1, m.foo());
360 })();
361
347 (function TestBadCase() { 362 (function TestBadCase() {
348 function Module() { 363 function Module() {
349 "use asm"; 364 "use asm";
350 function foo(x) { 365 function foo(x) {
351 x = x | 0; 366 x = x | 0;
352 switch (x|0) { 367 switch (x|0) {
353 case true: 368 case true:
354 return 42; 369 return 42;
355 default: 370 default:
356 return 43; 371 return 43;
357 } 372 }
358 return 0; 373 return 0;
359 } 374 }
360 return { foo: foo }; 375 return { foo: foo };
361 } 376 }
362 var m = Module(); 377 var m = Module();
363 assertFalse(%IsAsmWasmCode(Module)); 378 assertFalse(%IsAsmWasmCode(Module));
364 assertEquals(43, m.foo(3)); 379 assertEquals(43, m.foo(3));
365 })(); 380 })();
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698