Changeset 26be854 for tests/exceptions/hotpotato_checked.cfa
- Timestamp:
- Oct 1, 2023, 12:25:55 PM (13 months ago)
- Branches:
- master
- Children:
- 7a925a41
- Parents:
- fd775ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/exceptions/hotpotato_checked.cfa
rfd775ae r26be854 35 35 ExceptionDecl( Explode ); 36 36 ExceptionDecl( Terminate, Player * victim; ); 37 ExceptionDecl( Election , Player * player;);37 ExceptionDecl( Election ); 38 38 ExceptionDecl( cmd_error ); // convert(...) throws out_of_range or invalid_argument 39 39 … … 47 47 void countdown( Potato & potato ) with(potato) { 48 48 timer += 1; 49 if ( timer == deadline ) throw ExceptionInst( Explode );49 if ( timer == deadline ) throwResume ExceptionInst( Explode ); 50 50 } // countdown 51 51 … … 96 96 if ( partner[LEFT] == &player ) { // stop when only one player 97 97 sout | id | " wins the Match!"; 98 break;98 return; 99 99 } // exit 100 100 … … 116 116 sout | "election"; 117 117 sout | " -> " | id | nonl; 118 if ( id > getId( *election->player ) ) election->player= &player; // set umpire to highest id so far118 if ( id > getId( umpire ) ) &umpire = &player; // set umpire to highest id so far 119 119 resumeAt( *partner[RIGHT], *election ); 120 120 disable_ehm(); // disable ehm since we can't handle execption thrown in vote here and want to poll later 121 121 vote( *partner[RIGHT] ); 122 122 enable_ehm(); // enable after vote 123 } catch 123 } catchResume( Explode * ) { 124 124 sout | id | " is eliminated"; 125 125 if ( &player == &umpire ) { 126 126 try { 127 127 id = -1; // remove from election 128 resumeAt( *partner[RIGHT], ExceptionInst( Election , &player) );128 resumeAt( *partner[RIGHT], ExceptionInst( Election ) ); 129 129 vote( *partner[RIGHT] ); // start election 130 130 checked_poll(); 131 131 } catchResume( Election * election ) { 132 &umpire = election->player; 133 sout | " : umpire " | getId( *election->player ); 132 sout | " : umpire " | getId( umpire ); 134 133 } // try 135 134 } // if
Note: See TracChangeset
for help on using the changeset viewer.