ast-experimental
Last change
on this file since 8463136 was
d00d581,
checked in by Henry Xue <y58xue@…>, 3 years ago
|
Update exception tests to use new syntax
|
-
Property mode set to
100644
|
File size:
951 bytes
|
Rev | Line | |
---|
[ab8c6a6] | 1 | // Try cancelling a thread. |
---|
| 2 | |
---|
| 3 | #include <thread.hfa> |
---|
| 4 | |
---|
[d00d581] | 5 | exception internal_error {}; |
---|
| 6 | vtable(internal_error) internal_vt; |
---|
[ab8c6a6] | 7 | |
---|
| 8 | thread WillCancel {}; |
---|
| 9 | |
---|
| 10 | const char * msg(ThreadCancelled(WillCancel) * this) { |
---|
| 11 | return "ThreadCancelled(WillCancel)"; |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | void main(WillCancel &) { |
---|
| 15 | printf("1"); |
---|
[ecfd758] | 16 | cancel_stack((internal_error){&internal_vt}); |
---|
[ab8c6a6] | 17 | printf("!"); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | void explicit() { |
---|
| 21 | try { |
---|
| 22 | printf("0"); |
---|
| 23 | WillCancel cancel; |
---|
| 24 | printf("1"); |
---|
| 25 | join(cancel); |
---|
| 26 | printf("4"); |
---|
[8edbe40] | 27 | } catchResume (ThreadCancelled(WillCancel) * error) { |
---|
[ab8c6a6] | 28 | printf("2"); |
---|
| 29 | if ((virtual internal_error *)error->the_exception) { |
---|
| 30 | printf("3"); |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | printf("5\n"); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | void implicit() { |
---|
| 37 | try { |
---|
| 38 | { |
---|
| 39 | printf("0"); |
---|
| 40 | WillCancel cancel; |
---|
| 41 | printf("1"); |
---|
| 42 | } |
---|
| 43 | printf("4"); |
---|
[8edbe40] | 44 | } catchResume (ThreadCancelled(WillCancel) * error) { |
---|
[ab8c6a6] | 45 | printf("2"); |
---|
| 46 | if ((virtual internal_error *)error->the_exception) { |
---|
| 47 | printf("3"); |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | printf("5\n"); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | int main(int argc, char * argv[]) { |
---|
| 54 | explicit(); |
---|
| 55 | implicit(); |
---|
| 56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.