| 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 |
| 342 (function TestBadFroundTrue() { | 359 (function TestBadFroundTrue() { |
| 343 function Module(stdlib) { | 360 function Module(stdlib) { |
| 344 "use asm"; | 361 "use asm"; |
| 345 var fround = stdlib.Math.fround; | 362 var fround = stdlib.Math.fround; |
| 346 function foo() { | 363 function foo() { |
| 347 var x = fround(true); | 364 var x = fround(true); |
| 348 return +x; | 365 return +x; |
| 349 } | 366 } |
| 350 return { foo: foo }; | 367 return { foo: foo }; |
| 351 } | 368 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 var o = Module(); | 489 var o = Module(); |
| 473 assertValidAsm(Module); | 490 assertValidAsm(Module); |
| 474 assertFalse(o instanceof WebAssembly.Instance); | 491 assertFalse(o instanceof WebAssembly.Instance); |
| 475 assertTrue(o instanceof Object); | 492 assertTrue(o instanceof Object); |
| 476 assertTrue(o.__proto__ === Object.prototype); | 493 assertTrue(o.__proto__ === Object.prototype); |
| 477 o.x = 5; | 494 o.x = 5; |
| 478 assertTrue(typeof o.x === 'number'); | 495 assertTrue(typeof o.x === 'number'); |
| 479 assertTrue(o.__single_function__ === undefined); | 496 assertTrue(o.__single_function__ === undefined); |
| 480 assertTrue(o.__foreign_init__ === undefined); | 497 assertTrue(o.__foreign_init__ === undefined); |
| 481 })(); | 498 })(); |
| OLD | NEW |