ADT
        ast-experimental
        enum
        pthread-emulation
        qualifiedEnum
      
      
        
          | Last change
 on this file since 928128d was             d00d581, checked in by Henry Xue <y58xue@…>, 4 years ago | 
        
          | 
Update exception tests to use new syntax
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            817 bytes | 
      
      
| Line |  | 
|---|
| 1 | // Conditional Catch Test | 
|---|
| 2 |  | 
|---|
| 3 | // I may fold this back into terminate.cfa and resume.cfa once setting | 
|---|
| 4 | // up the non-trivial exception is reasonable to do. | 
|---|
| 5 |  | 
|---|
| 6 | exception num_error { | 
|---|
| 7 | int num; | 
|---|
| 8 | }; | 
|---|
| 9 |  | 
|---|
| 10 | vtable(num_error) num_error_vt; | 
|---|
| 11 |  | 
|---|
| 12 | void caught_num_error(int expect, num_error * actual) { | 
|---|
| 13 | printf("Caught num_error: expected=%d actual=%d.\n", expect, actual->num); | 
|---|
| 14 | } | 
|---|
| 15 |  | 
|---|
| 16 | int main(int argc, char * argv[]) { | 
|---|
| 17 | num_error exc = {&num_error_vt, 2}; | 
|---|
| 18 |  | 
|---|
| 19 | try { | 
|---|
| 20 | throw exc; | 
|---|
| 21 | } catch (num_error * error ; 3 == error->num ) { | 
|---|
| 22 | caught_num_error(3, error); | 
|---|
| 23 | } catch (num_error * error ; 2 == error->num ) { | 
|---|
| 24 | caught_num_error(2, error); | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|
| 27 | try { | 
|---|
| 28 | throwResume exc; | 
|---|
| 29 | } catchResume (num_error * error ; 3 == error->num ) { | 
|---|
| 30 | caught_num_error(3, error); | 
|---|
| 31 | } catchResume (num_error * error ; 2 == error->num ) { | 
|---|
| 32 | caught_num_error(2, error); | 
|---|
| 33 | } | 
|---|
| 34 | } | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.