aboutsummaryrefslogtreecommitdiffstats
path: root/tests/pureJava/SwitchStmtLocals.java
blob: 8e610020be99240d5c4ffa941db299d8296145c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import org.aspectj.testing.Tester;

public class SwitchStmtLocals {
    public static void main(String[] args) {
        new SwitchStmtLocals().realMain(args);
    }

    int i = 40;
    public void realMain(String[] args) {

        int val;

        val = 1;
        i = 40;
        switch (val) {
        case 0:  int   i = 10; break;
        case 1:  val = i = 20; break;
        default: val = i = 30; break;
        }
        Tester.checkEqual(val, 20);
        Tester.checkEqual(i, 40);

        val = 1;
        i = 40;
        switch (val) {
        case 0:  int   i = 10; break;
        case 1:
            switch (val-1) {
            case 0:  val = i = 20; break;
            default: val = i = 30; break;
            }
            break;
        default:       i = 30; break;
        }
        Tester.checkEqual(val, 20);
        Tester.checkEqual(i, 40);

        val = 1;
        i = 40;
        switch (val) {
        case 0:  int   i = 10; break;
        case 1:
            switch (val-1) {
            case 0:
                switch (val-1) {
                case 0:  val = i = 20; break;
                default: val = i = 30; break;
                }
                break;
            default: val = i = 30; break;
            }
            break;
        default:       i = 30; break;
        }
        Tester.checkEqual(val, 20);
        Tester.checkEqual(i, 40);
    }
}