-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- checks correct function of `ON ERROR GOTO label` in conjuction with `ON ERROR GOTO _LASTHANDLER`
- Loading branch information
1 parent
ffce952
commit 48099fe
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
$CONSOLE:ONLY | ||
|
||
'interfacing internal variables | ||
DECLARE LIBRARY "errtest" | ||
FUNCTION GetErrorHistory$ | ||
FUNCTION GetErrorGotoLine& | ||
END DECLARE | ||
|
||
'testing handler behavior | ||
Status | ||
ON ERROR GOTO mainHandler | ||
Status | ||
ERROR 5 | ||
NormalTest | ||
ERROR 5 | ||
RecursiveTest 3 | ||
ERROR 5 | ||
ON ERROR GOTO _LASTHANDLER | ||
Status | ||
|
||
'return to test script | ||
SYSTEM | ||
|
||
'----------------------------------------------------------------------- | ||
mainHandler: | ||
PRINT " CALLED: main handler" | ||
RESUME NEXT | ||
'----- | ||
nSubHandler: | ||
PRINT " CALLED: normal sub handler" | ||
RESUME NEXT | ||
'----- | ||
rSubHandler: | ||
PRINT " CALLED: recursive sub handler" | ||
RESUME NEXT | ||
|
||
'----------------------------------------------------------------------- | ||
SUB NormalTest | ||
ON ERROR GOTO nSubHandler | ||
Status | ||
ERROR 5 | ||
ON ERROR GOTO _LASTHANDLER | ||
Status | ||
END SUB | ||
'----- | ||
SUB RecursiveTest (n%) | ||
ON ERROR GOTO rSubHandler | ||
Status | ||
ERROR 5 | ||
IF n% > 1 THEN RecursiveTest n% - 1 | ||
ON ERROR GOTO _LASTHANDLER | ||
Status | ||
END SUB | ||
|
||
'----------------------------------------------------------------------- | ||
SUB Status | ||
PRINT: PRINT "HISTORY: "; "<"; GetErrorHistory$; ">" | ||
SELECT CASE GetErrorGotoLine& | ||
CASE 0: PRINT " ACTIVE: unhandled" | ||
CASE 1: PRINT " ACTIVE: main handler" | ||
CASE 2: PRINT " ACTIVE: normal sub handler" | ||
CASE 3: PRINT " ACTIVE: recursive sub handler" | ||
END SELECT | ||
END SUB | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
unsigned char cont[256]; | ||
|
||
unsigned char *GetErrorHistory() { | ||
memset(cont, 0, 256); | ||
memcpy (cont, error_handler_history -> chr, error_handler_history -> len); | ||
return cont; | ||
} | ||
|
||
uint32_t GetErrorGotoLine() { | ||
return error_goto_line; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
HISTORY: <> | ||
ACTIVE: unhandled | ||
|
||
HISTORY: < 0|> | ||
ACTIVE: main handler | ||
CALLED: main handler | ||
|
||
HISTORY: < 1| 0|> | ||
ACTIVE: normal sub handler | ||
CALLED: normal sub handler | ||
|
||
HISTORY: < 0|> | ||
ACTIVE: main handler | ||
CALLED: main handler | ||
|
||
HISTORY: < 1| 0|> | ||
ACTIVE: recursive sub handler | ||
CALLED: recursive sub handler | ||
|
||
HISTORY: < 3| 1| 0|> | ||
ACTIVE: recursive sub handler | ||
CALLED: recursive sub handler | ||
|
||
HISTORY: < 3| 3| 1| 0|> | ||
ACTIVE: recursive sub handler | ||
CALLED: recursive sub handler | ||
|
||
HISTORY: < 3| 1| 0|> | ||
ACTIVE: recursive sub handler | ||
|
||
HISTORY: < 1| 0|> | ||
ACTIVE: recursive sub handler | ||
|
||
HISTORY: < 0|> | ||
ACTIVE: main handler | ||
CALLED: main handler | ||
|
||
HISTORY: <> | ||
ACTIVE: unhandled |