source: tests/exceptions/cancel/thread.cfa@ b28ce93

Last change on this file since b28ce93 was d3cf623, checked in by Andrew Beach <ajbeach@…>, 9 months ago

Solved the requested warning with exceptions. Also went through the exceptions tests and managed to remove about 2/3rds of them from the lax list that now either didn't have any warnings or warnings because of the test itself.

  • Property mode set to 100644
File size: 953 bytes
RevLine 
[ab8c6a6]1// Try cancelling a thread.
2
[3bf9d10]3#include <fstream.hfa>
[ab8c6a6]4#include <thread.hfa>
5
[d00d581]6exception internal_error {};
7vtable(internal_error) internal_vt;
[ab8c6a6]8
9thread WillCancel {};
10
[d3cf623]11const char * msg(ThreadCancelled(WillCancel) *) {
[ab8c6a6]12 return "ThreadCancelled(WillCancel)";
13}
14
15void main(WillCancel &) {
[3bf9d10]16 sout | '1';
[ecfd758]17 cancel_stack((internal_error){&internal_vt});
[3bf9d10]18 sout | '!';
[ab8c6a6]19}
20
21void explicit() {
22 try {
[3bf9d10]23 sout | '0';
[ab8c6a6]24 WillCancel cancel;
[3bf9d10]25 sout | '1';
[ab8c6a6]26 join(cancel);
[3bf9d10]27 sout | '4';
[8edbe40]28 } catchResume (ThreadCancelled(WillCancel) * error) {
[3bf9d10]29 sout | '2';
[ab8c6a6]30 if ((virtual internal_error *)error->the_exception) {
[3bf9d10]31 sout | '3';
[ab8c6a6]32 }
33 }
[3bf9d10]34 sout | '5' | nl;
[ab8c6a6]35}
36
37void implicit() {
38 try {
39 {
[3bf9d10]40 sout | '0';
[ab8c6a6]41 WillCancel cancel;
[3bf9d10]42 sout | '1';
[ab8c6a6]43 }
[3bf9d10]44 sout | '4';
[8edbe40]45 } catchResume (ThreadCancelled(WillCancel) * error) {
[3bf9d10]46 sout | '2';
[ab8c6a6]47 if ((virtual internal_error *)error->the_exception) {
[3bf9d10]48 sout | '3';
[ab8c6a6]49 }
50 }
[3bf9d10]51 sout | '5' | nl;
[ab8c6a6]52}
53
[d3cf623]54int main() {
[3bf9d10]55 sout | nlOff;
[ab8c6a6]56 explicit();
57 implicit();
58}
Note: See TracBrowser for help on using the repository browser.