mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
added a function to check for errors without clearing them
This commit is contained in:
parent
cbe99e6089
commit
3d8627410f
@ -504,6 +504,15 @@ bool pkpy_check_global(pkpy_vm* vm_handle, const char* name) {
|
||||
SAFEGUARD_CLOSE
|
||||
}
|
||||
|
||||
bool pkpy_check_error(pkpy_vm* vm_handle) {
|
||||
CVM* vm = (CVM*) vm_handle;
|
||||
SAFEGUARD_OPEN
|
||||
if (vm->c_data->size() > 0 && vm->c_data->top() == nullptr)
|
||||
return true;
|
||||
return false;
|
||||
SAFEGUARD_CLOSE
|
||||
}
|
||||
|
||||
|
||||
bool pkpy_check_stack(pkpy_vm* vm_handle, int free) {
|
||||
CVM* vm = (CVM*) vm_handle;
|
||||
|
@ -87,6 +87,9 @@ bool pkpy_is_none(pkpy_vm*, int index);
|
||||
//will return true if global exists
|
||||
bool pkpy_check_global(pkpy_vm*, const char* name);
|
||||
|
||||
//will return true if the vm is currently in an error state
|
||||
bool pkpy_check_error(pkpy_vm*);
|
||||
|
||||
//will return true if at least free empty slots remain on the stack
|
||||
bool pkpy_check_stack(pkpy_vm*, int free);
|
||||
|
||||
|
@ -293,6 +293,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
check(pkpy_check_global(vm, "test_error_propagate"));
|
||||
fail(pkpy_check_global(vm, "nonexistant"));
|
||||
pkpy_vm_run(vm, "test_error_propagate()");
|
||||
check(pkpy_check_error(vm));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ echo "checking results (they should be identical)"
|
||||
diff -q -s binding_test_scratch c_bindings/test_answers.txt
|
||||
|
||||
echo "cleaning up"
|
||||
#rm pocketpy_c.o
|
||||
rm pocketpy_c.o
|
||||
rm test.o
|
||||
rm binding_test_scratch
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user