| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 "use asm"; | 295 "use asm"; |
| 296 const i = 0xffffffff; | 296 const i = 0xffffffff; |
| 297 function foo() { return i; } | 297 function foo() { return i; } |
| 298 return { foo: foo }; | 298 return { foo: foo }; |
| 299 } | 299 } |
| 300 var m = Module(); | 300 var m = Module(); |
| 301 assertFalse(%IsAsmWasmCode(Module)); | 301 assertFalse(%IsAsmWasmCode(Module)); |
| 302 assertEquals(0xffffffff, m.foo()); | 302 assertEquals(0xffffffff, m.foo()); |
| 303 })(); | 303 })(); |
| 304 | 304 |
| 305 (function TestBadBooleanAnnotation() { | 305 (function TestBadBooleanParamAnnotation() { |
| 306 function Module() { | 306 function Module() { |
| 307 "use asm"; | 307 "use asm"; |
| 308 function foo(x) { | 308 function foo(x) { |
| 309 x = x | true; | 309 x = x | true; |
| 310 return x; | 310 return x; |
| 311 } | 311 } |
| 312 return { foo: foo }; | 312 return { foo: foo }; |
| 313 } | 313 } |
| 314 var m = Module(); | 314 var m = Module(); |
| 315 assertFalse(%IsAsmWasmCode(Module)); | 315 assertFalse(%IsAsmWasmCode(Module)); |
| 316 assertEquals(3, m.foo(3)); | 316 assertEquals(3, m.foo(3)); |
| 317 })(); | 317 })(); |
| 318 | 318 |
| 319 (function TestBadishBooleanExprAnnotation() { |
| 320 function Module() { |
| 321 "use asm"; |
| 322 function foo(x) { |
| 323 x = x | 0; |
| 324 x = (x + 1) | false; |
| 325 return x | 0; |
| 326 } |
| 327 return { foo: foo }; |
| 328 } |
| 329 var m = Module(); |
| 330 // We all false here because the parser optimizes expressons like: |
| 331 // !123 to false. |
| 332 assertTrue(%IsAsmWasmCode(Module)); |
| 333 assertEquals(4, m.foo(3)); |
| 334 })(); |
| 335 |
| 319 (function TestBadCase() { | 336 (function TestBadCase() { |
| 320 function Module() { | 337 function Module() { |
| 321 "use asm"; | 338 "use asm"; |
| 322 function foo(x) { | 339 function foo(x) { |
| 323 x = x | 0; | 340 x = x | 0; |
| 324 switch (x|0) { | 341 switch (x|0) { |
| 325 case true: | 342 case true: |
| 326 return 42; | 343 return 42; |
| 327 default: | 344 default: |
| 328 return 43; | 345 return 43; |
| 329 } | 346 } |
| 330 return 0; | 347 return 0; |
| 331 } | 348 } |
| 332 return { foo: foo }; | 349 return { foo: foo }; |
| 333 } | 350 } |
| 334 var m = Module(); | 351 var m = Module(); |
| 335 assertFalse(%IsAsmWasmCode(Module)); | 352 assertFalse(%IsAsmWasmCode(Module)); |
| 336 assertEquals(43, m.foo(3)); | 353 assertEquals(43, m.foo(3)); |
| 337 })(); | 354 })(); |
| OLD | NEW |