OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
3 * for details. All rights reserved. Use of this source code is governed by a | |
4 * BSD-style license that can be found in the LICENSE file. | |
5 */ | |
6 | |
7 // Slightly modified copy of | |
8 // `co19/src/Language/Statements/Switch/execution_case_t02.dart`. | |
9 | |
10 /** | |
11 * @assertion Execution of a case clause case ek: sk of a switch statement | |
12 * switch (e) {label11 ..label1j1 case e1: s1 … labeln1 ..labelnjn case en: sn d
efault: sn+1} | |
13 * proceeds as follows: | |
14 * The expression ek == id is evaluated to an object o which is then | |
15 * subjected to boolean conversion yielding a value v. | |
16 * If v is not true, the following case, case ek+1: sk+1 is executed if it exis
ts. | |
17 * If case ek+1: sk+1 does not exist, then the default clause is executed by exe
cuting sn+1. | |
18 * If v is true, let h be the smallest integer such that h >= k and sh is non-em
pty. | |
19 * If no such h exists, let h = n + 1. The sequence of statements sh is then exe
cuted. | |
20 * If execution reaches the point after sh then a runtime error occurs, unless
h = n + 1. | |
21 * @description Checks that falling through produces a runtime error, unless | |
22 * the current clause is an empty case clause or the default clause. | |
23 * @static-warning | |
24 * @author msyabro | |
25 * @reviewer rodionov | |
26 * @issue 7537 | |
27 */ | |
28 | |
29 test(value) { | |
30 var result; | |
31 | |
32 switch(value) { | |
33 case 1: result = 1; | |
34 break; | |
35 case 2: result = 2; /// static warning - case fall-through, see "Switch" | |
36 case 3: result = 3; /// static warning - case fall-through, see "Switch" | |
37 default: result = 4; | |
38 } | |
39 return result; | |
40 } | |
41 | |
42 testEmptyCases(value) { | |
43 var result; | |
44 | |
45 switch(value) { | |
46 case 1: | |
47 case 2: result = 1; /// static warning - case fall-through, see "Switch" | |
48 case 3: | |
49 case 4: result = 2; | |
50 break; | |
51 case 5: | |
52 case 6: | |
53 default: | |
54 } | |
55 | |
56 return result; | |
57 } | |
58 | |
59 main() { | |
60 } | |
OLD | NEW |