Mercurial > projects > dstress
annotate run/s/switch_22_C.d @ 1604:cc724d521a34
Add note about possible issues with test case depending on switch scopes.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 28 Mar 2009 19:17:58 +0100 |
parents | 986983b8cf7a |
children |
rev | line source |
---|---|
1060 | 1 // $HeadURL$ |
2 // $Date$ | |
3 // $Author$ | |
4 | |
5 // @author@ <BCS@pathlink.com> | |
6 // @date@ 2006-06-16 | |
7 // @uri@ news:e6umde$2ok0$2@digitaldaemon.com | |
1336 | 8 // @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=729 |
1060 | 9 |
10 module dstress.run.s.switch_22_C; | |
11 | |
1604
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
12 /+ |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
13 The validity of this test case is dubious: |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
14 the spec is not explicit about scopes in a switch statement |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
15 and DMD transforms the scope(success) into: |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
16 |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
17 switch(3){ |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
18 bool success = true; |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
19 try { default: } |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
20 catch(Object e) { success = false; throw e; } |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
21 finally { if(success) i--; } |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
22 } |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
23 +/ |
cc724d521a34
Add note about possible issues with test case depending on switch scopes.
Christian Kamm <kamm incasoftware de>
parents:
1336
diff
changeset
|
24 |
1060 | 25 int main(){ |
1061 | 26 int i = 2; |
1060 | 27 |
1061 | 28 switch(3){ |
1060 | 29 scope(success) i--; |
30 | |
31 default: | |
32 } | |
33 | |
1061 | 34 if(i != 2){ |
1060 | 35 assert(0); |
36 } | |
37 | |
38 return 0; | |
39 } |