py/runtime: Refactor assert(0) to improve coverage.

This commit is contained in:
Damien George 2017-01-17 00:09:56 +11:00
parent 751e379533
commit 40863fce6f
1 changed files with 2 additions and 4 deletions

View File

@ -1234,7 +1234,8 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
return MP_VM_RETURN_YIELD; return MP_VM_RETURN_YIELD;
} }
if (throw_value != MP_OBJ_NULL) { assert(throw_value != MP_OBJ_NULL);
{
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(throw_value)), MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) { if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type(throw_value)), MP_OBJ_FROM_PTR(&mp_type_GeneratorExit))) {
mp_load_method_maybe(self_in, MP_QSTR_close, dest); mp_load_method_maybe(self_in, MP_QSTR_close, dest);
if (dest[0] != MP_OBJ_NULL) { if (dest[0] != MP_OBJ_NULL) {
@ -1260,9 +1261,6 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th
*ret_val = throw_value; *ret_val = throw_value;
return MP_VM_RETURN_EXCEPTION; return MP_VM_RETURN_EXCEPTION;
} }
assert(0);
return MP_VM_RETURN_NORMAL; // Should be unreachable
} }
mp_obj_t mp_make_raise_obj(mp_obj_t o) { mp_obj_t mp_make_raise_obj(mp_obj_t o) {