forked from mirrors/ubasic
fix
This commit is contained in:
parent
cc07193c23
commit
155ce36531
5 changed files with 114 additions and 18 deletions
25
tests.c
25
tests.c
|
|
@ -76,6 +76,20 @@ static const char program_peek_poke[] =
|
|||
50 end\n";
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const char program_div_zero[] =
|
||||
"10 let a = 1\n\
|
||||
20 let b = a / 0\n\
|
||||
30 let a = 2\n\
|
||||
40 end\n";
|
||||
|
||||
static const char program_bad_goto[] =
|
||||
"10 goto 999\n\
|
||||
20 end\n";
|
||||
|
||||
static const char program_unterminated[] =
|
||||
"10 print \"oops\n\
|
||||
20 end\n";
|
||||
|
||||
VARIABLE_TYPE peek(VARIABLE_TYPE arg) {
|
||||
return arg;
|
||||
}
|
||||
|
|
@ -128,6 +142,17 @@ main(void)
|
|||
run(program_peek_poke);
|
||||
assert(ubasic_get_variable(0) == 123);
|
||||
assert(ubasic_get_variable(25) == 123);
|
||||
assert(ubasic_error() == UBASIC_OK);
|
||||
|
||||
run(program_div_zero);
|
||||
assert(ubasic_error() == UBASIC_ERR_DIV_ZERO);
|
||||
assert(ubasic_get_variable(0) == 1); /* line 30 never ran */
|
||||
|
||||
run(program_bad_goto);
|
||||
assert(ubasic_error() == UBASIC_ERR_NO_LINE);
|
||||
|
||||
run(program_unterminated);
|
||||
assert(ubasic_error() == UBASIC_ERR_SYNTAX);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue