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 function assertValidAsm(func) { | 7 function assertValidAsm(func) { |
8 assertTrue(%IsAsmWasmCode(func)); | 8 assertTrue(%IsAsmWasmCode(func)); |
9 } | 9 } |
10 | 10 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 function Module() { | 288 function Module() { |
289 "use asm"; | 289 "use asm"; |
290 const i = 0xffffffff; | 290 const i = 0xffffffff; |
291 function foo() { return i; } | 291 function foo() { return i; } |
292 return { foo: foo }; | 292 return { foo: foo }; |
293 } | 293 } |
294 var m = Module(); | 294 var m = Module(); |
295 assertTrue(%IsNotAsmWasmCode(Module)); | 295 assertTrue(%IsNotAsmWasmCode(Module)); |
296 assertEquals(0xffffffff, m.foo()); | 296 assertEquals(0xffffffff, m.foo()); |
297 })(); | 297 })(); |
| 298 |
| 299 (function TestBadBooleanAnnotation() { |
| 300 function Module() { |
| 301 "use asm"; |
| 302 function foo(x) { |
| 303 x = x | true; |
| 304 return x; |
| 305 } |
| 306 return { foo: foo }; |
| 307 } |
| 308 var m = Module(); |
| 309 assertTrue(%IsNotAsmWasmCode(Module)); |
| 310 assertEquals(3, m.foo(3)); |
| 311 })(); |
| 312 |
| 313 (function TestBadCase() { |
| 314 function Module() { |
| 315 "use asm"; |
| 316 function foo(x) { |
| 317 x = x | 0; |
| 318 switch (x|0) { |
| 319 case true: |
| 320 return 42; |
| 321 default: |
| 322 return 43; |
| 323 } |
| 324 return 0; |
| 325 } |
| 326 return { foo: foo }; |
| 327 } |
| 328 var m = Module(); |
| 329 assertTrue(%IsNotAsmWasmCode(Module)); |
| 330 assertEquals(43, m.foo(3)); |
| 331 })(); |
OLD | NEW |