OLD | NEW |
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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 function Module(stdlib) { | 332 function Module(stdlib) { |
333 "use asm"; | 333 "use asm"; |
334 var set = 0; | 334 var set = 0; |
335 var foo = stdlib[set]; | 335 var foo = stdlib[set]; |
336 return {}; | 336 return {}; |
337 } | 337 } |
338 var m = Module(this); | 338 var m = Module(this); |
339 assertFalse(%IsAsmWasmCode(Module)); | 339 assertFalse(%IsAsmWasmCode(Module)); |
340 })(); | 340 })(); |
341 | 341 |
342 (function TestBadishBooleanExprAnnotation() { | |
343 function Module() { | |
344 "use asm"; | |
345 function foo(x) { | |
346 x = x | 0; | |
347 x = (x + 1) | false; | |
348 return x | 0; | |
349 } | |
350 return { foo: foo }; | |
351 } | |
352 var m = Module(); | |
353 // We all false here because the parser optimizes expressons like: | |
354 // !123 to false. | |
355 assertTrue(%IsAsmWasmCode(Module)); | |
356 assertEquals(4, m.foo(3)); | |
357 })(); | |
358 | |
359 (function TestBadFroundTrue() { | 342 (function TestBadFroundTrue() { |
360 function Module(stdlib) { | 343 function Module(stdlib) { |
361 "use asm"; | 344 "use asm"; |
362 var fround = stdlib.Math.fround; | 345 var fround = stdlib.Math.fround; |
363 function foo() { | 346 function foo() { |
364 var x = fround(true); | 347 var x = fround(true); |
365 return +x; | 348 return +x; |
366 } | 349 } |
367 return { foo: foo }; | 350 return { foo: foo }; |
368 } | 351 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 var o = Module(); | 472 var o = Module(); |
490 assertValidAsm(Module); | 473 assertValidAsm(Module); |
491 assertFalse(o instanceof WebAssembly.Instance); | 474 assertFalse(o instanceof WebAssembly.Instance); |
492 assertTrue(o instanceof Object); | 475 assertTrue(o instanceof Object); |
493 assertTrue(o.__proto__ === Object.prototype); | 476 assertTrue(o.__proto__ === Object.prototype); |
494 o.x = 5; | 477 o.x = 5; |
495 assertTrue(typeof o.x === 'number'); | 478 assertTrue(typeof o.x === 'number'); |
496 assertTrue(o.__single_function__ === undefined); | 479 assertTrue(o.__single_function__ === undefined); |
497 assertTrue(o.__foreign_init__ === undefined); | 480 assertTrue(o.__foreign_init__ === undefined); |
498 })(); | 481 })(); |
OLD | NEW |