File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11PYTHONPATH =../../:.
22CLASSPATH: =.:/usr/share/junit/lib/junit.jar
33
4- PYOBJS =AssignInExpr.py EmptyArray.py
5- JAVAOBJS =AssignInExpr EmptyArray
4+ PYOBJS =AssignInExpr.py EmptyArray.py Switches.py
5+ JAVAOBJS =AssignInExpr EmptyArray Switches
66
77all : python-test
88
Original file line number Diff line number Diff line change 1- class Switches {
2- public static void main (String [] args ) {
3- System .out .println ( switches () );
4- }
1+ import junit .framework .*;
2+
3+ public class Switches extends TestCase {
4+
5+ public void testSwitches () {
6+ Assert .assertEquals (switch1 (1 ), 1 );
7+ Assert .assertEquals (switch1 (2 ), 2 );
8+ Assert .assertEquals (switch1 (3 ), 10 );
9+ Assert .assertEquals (switch1 (10 ), 4 );
10+
11+ Assert .assertEquals (switch2 (3 ), 2 );
12+ Assert .assertEquals (switch2 (3 ), 2 );
513
6- public static int switches () {
7- int i ;
8- i = 3 ;
14+ Assert .assertEquals (switch3 (3 ), 4 );
915
16+ Assert .assertEquals (switch4 (1 ), 1 );
17+ Assert .assertEquals (switch4 (3 ), 2 );
18+ }
19+
20+ public int switch1 (int i ) {
1021 switch (i ) {
1122 case 1 :
1223 case 2 :
1324 break ;
1425 case 3 :
15- i = 2 ;
26+ i = 10 ;
27+ break ;
1628 default :
17- return - 4 ;
29+ i = 4 ;
1830 }
31+ return i ;
32+ }
1933
34+ public int switch2 (int i ) {
2035 switch (i ) {
2136 case 3 :
2237 default :
2338 i = 2 ;
24- }
25- return - 1 ;
39+ }
40+ return i ;
2641 }
2742
28- }
43+ public int switch3 (int i ) {
44+ switch (i ) {
45+ case 1 :
46+ case 2 :
47+ break ;
48+ case 3 :
49+ i = 10 ;
50+ default :
51+ i = 4 ;
52+ }
53+ return i ;
54+ }
2955
56+ public int switch4 (int i ) {
57+ switch (i ) {
58+ case 1 :
59+ if (i == 1 ) break ;
60+ default :
61+ i = 2 ;
62+ }
63+ return i ;
64+ }
65+
66+ }
You can’t perform that action at this time.
0 commit comments