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: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
| 7 (function TestSwitch0() { |
| 8 function asmModule() { |
| 9 "use asm" |
| 10 |
| 11 function caller() { |
| 12 var ret = 0; |
| 13 var x = 7; |
| 14 switch (x) { |
| 15 case 1: { |
| 16 return 0; |
| 17 } |
| 18 case 7: { |
| 19 ret = 5; |
| 20 break; |
| 21 } |
| 22 default: return 0; |
| 23 } |
| 24 return ret|0; |
| 25 } |
| 26 |
| 27 return {caller:caller}; |
| 28 } |
| 29 var wasm = Wasm.instantiateModuleFromAsm(asmModule.toString()); |
| 30 assertEquals(5, wasm.caller()); |
| 31 })(); |
| 32 |
7 (function TestSwitch() { | 33 (function TestSwitch() { |
8 function asmModule() { | 34 function asmModule() { |
9 "use asm" | 35 "use asm" |
10 | 36 |
11 function caller() { | 37 function caller() { |
12 var ret = 0; | 38 var ret = 0; |
13 var x = 7; | 39 var x = 7; |
14 switch (x) { | 40 switch (x) { |
15 case 1: return 0; | 41 case 1: return 0; |
16 case 7: { | 42 case 7: { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 if (k != 56) return "break;"; | 459 if (k != 56) return "break;"; |
434 else return "return 23;"; | 460 else return "return 23;"; |
435 } | 461 } |
436 wasm = LargeSwitchGenerator(0, 638, 2, handle_case); | 462 wasm = LargeSwitchGenerator(0, 638, 2, handle_case); |
437 for (var i = 0; i <= 638; i = i + 2) { | 463 for (var i = 0; i <= 638; i = i + 2) { |
438 if (i == 56) assertEquals(23, wasm.main(i)); | 464 if (i == 56) assertEquals(23, wasm.main(i)); |
439 else assertEquals(-2, wasm.main(i)); | 465 else assertEquals(-2, wasm.main(i)); |
440 } | 466 } |
441 assertEquals(-1, wasm.main(-1)); | 467 assertEquals(-1, wasm.main(-1)); |
442 })(); | 468 })(); |
OLD | NEW |