Use new BYE-CODE to pass an error back to the shell.
Use test tools for t_alloc.fth
Fixes #82
- name: Test
working-directory: ${{github.workspace}}/fth
run: |
- ./pforth_standalone t_corex.fth | tee temp.txt && grep "0 failed" temp.txt
- ./pforth_standalone t_strings.fth | tee temp.txt && grep "0 failed" temp.txt
- ./pforth_standalone t_locals.fth | tee temp.txt && grep "0 failed" temp.txt
- ./pforth_standalone t_alloc.fth | tee temp.txt && grep "PASSED" temp.txt
-
+ ./pforth_standalone t_corex.fth
+ ./pforth_standalone t_strings.fth
+ ./pforth_standalone t_locals.fth
+ ./pforth_standalone t_alloc.fth
+ ./pforth_standalone t_floats.fth
+ ./pforth_standalone t_file.fth
cell_t gVarContext; /* Points to last name field. */
cell_t gVarState; /* 1 if compiling. */
cell_t gVarBase; /* Numeric Base. */
-cell_t gVarEcho; /* Echo input. */
+cell_t gVarByeCode; /* Echo input. */
+cell_t gVarEcho; /* Echo input. */
cell_t gVarTraceLevel; /* Trace Level for Inner Interpreter. */
cell_t gVarTraceStack; /* Dump Stack each time if true. */
cell_t gVarTraceFlags; /* Enable various internal debug messages. */
PF_USER_TERM;
#endif
- return Result;
+ return Result ? Result : gVarByeCode;
error2:
MSG("pfDoForth: Error occured.\n");
ID_FILE_RENAME, /* (RENAME-FILE) */
ID_FILE_RESIZE, /* RESIZE-FILE */
ID_SLEEP_P, /* (SLEEP) V2.0.0 */
-/* If you add a word here, take away one reserved word below. */
+ ID_VAR_BYE_CODE, /* BYE-CODE */
+ /* If you add a word here, take away one reserved word below. */
#ifdef PF_SUPPORT_FP
/* Only reserve space if we are adding FP so that we can detect
** unsupported primitives when loading dictionary.
*/
- ID_RESERVED01,
ID_RESERVED02,
ID_RESERVED03,
ID_RESERVED04,
extern cell_t gVarContext; /* Points to last name field. */
extern cell_t gVarState; /* 1 if compiling. */
extern cell_t gVarBase; /* Numeric Base. */
+extern cell_t gVarByeCode; /* BYE-CODE returned on exit */
extern cell_t gVarEcho; /* Echo input from file. */
extern cell_t gVarEchoAccept; /* Echo input from ACCEPT. */
extern cell_t gVarTraceLevel;
endcase;
case ID_VAR_BASE: DO_VAR(gVarBase); endcase;
+ case ID_VAR_BYE_CODE: DO_VAR(gVarByeCode); endcase;
case ID_VAR_CODE_BASE: DO_VAR(gCurrentDictionary->dic_CodeBase); endcase;
case ID_VAR_CODE_LIMIT: DO_VAR(gCurrentDictionary->dic_CodeLimit); endcase;
case ID_VAR_CONTEXT: DO_VAR(gVarContext); endcase;
CreateDicEntryC( ID_TO_R, ">R", 0 );
CreateDicEntryC( ID_TYPE, "TYPE", 0 );
CreateDicEntryC( ID_VAR_BASE, "BASE", 0 );
+ CreateDicEntryC( ID_VAR_BYE_CODE, "BYE-CODE", 0 );
CreateDicEntryC( ID_VAR_CODE_BASE, "CODE-BASE", 0 );
CreateDicEntryC( ID_VAR_CODE_LIMIT, "CODE-LIMIT", 0 );
CreateDicEntryC( ID_VAR_CONTEXT, "CONTEXT", 0 );
\
\ Copyright 1994 3DO, Phil Burk
+INCLUDE? }T{ t_tools.fth
+
anew task-t_alloc.fth
decimal
THEN
;
-: TAF.TERM
+: TAF.TERM ( -- error , 0 if PASSED )
NUM_TAF_SLOTS 0
DO
i taf-addresses @
\
taf.max.alloc? dup ." Final MAX = " . cr
." Original MAX = " taf-max-alloc @ dup . cr
- = IF ." Test PASSED." ELSE ." Test FAILED!" THEN cr
+ = IF ." Test PASSED." 0
+ ELSE ." Test FAILED!" 1
+ THEN cr
;
;
.( Testing ALLOCATE and FREE) cr
-10000 taf.test
+
+TEST{
+
+T{ 10000 taf.test }T{ 0 }T
+
+}TEST
variable TEST-DEPTH
variable TEST-PASSED
variable TEST-FAILED
+40 constant TEST_EXIT_FAILURE \ returned form pForth to shell
: TEST{
- depth test-depth !
- 0 test-passed !
- 0 test-failed !
+ depth test-depth !
+ 0 test-passed !
+ 0 test-failed !
;
: }TEST
- test-passed @ 4 .r ." passed, "
- test-failed @ 4 .r ." failed." cr
+ test-passed @ 4 .r ." passed, "
+ test-failed @ 4 .r ." failed." cr
+ test-failed @ 0> IF
+ TEST_EXIT_FAILURE bye-code !
+ THEN
;
wd=$$(pwd); (cd $(FTHDIR); $${wd}/$(PFORTHAPP) -q t_alloc.fth)
wd=$$(pwd); (cd $(FTHDIR); $${wd}/$(PFORTHAPP) -q t_floats.fth)
wd=$$(pwd); (cd $(FTHDIR); $${wd}/$(PFORTHAPP) -q t_file.fth)
+ @echo "PForth Tests PASSED"
clean:
rm -f $(PFOBJS) $(PFEMBOBJS)