summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/unix/coverage.c23
-rw-r--r--tests/unix/extra_coverage.py.exp4
2 files changed, 27 insertions, 0 deletions
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c
index 6623cb464..6cd84dc30 100644
--- a/ports/unix/coverage.c
+++ b/ports/unix/coverage.c
@@ -334,6 +334,29 @@ STATIC mp_obj_t extra_coverage(void) {
mp_call_function_2_protected(MP_OBJ_FROM_PTR(&mp_builtin_divmod_obj), MP_OBJ_NEW_SMALL_INT(1), MP_OBJ_NEW_SMALL_INT(1));
// call mp_call_function_2_protected with invalid args
mp_call_function_2_protected(MP_OBJ_FROM_PTR(&mp_builtin_divmod_obj), mp_obj_new_str("abc", 3), mp_obj_new_str("abc", 3));
+
+ // mp_obj_int_get_uint_checked with non-negative small-int
+ mp_printf(&mp_plat_print, "%d\n", (int)mp_obj_int_get_uint_checked(MP_OBJ_NEW_SMALL_INT(1)));
+
+ // mp_obj_int_get_uint_checked with non-negative big-int
+ mp_printf(&mp_plat_print, "%d\n", (int)mp_obj_int_get_uint_checked(mp_obj_new_int_from_ll(2)));
+
+ // mp_obj_int_get_uint_checked with negative small-int (should raise exception)
+ nlr_buf_t nlr;
+ if (nlr_push(&nlr) == 0) {
+ mp_obj_int_get_uint_checked(MP_OBJ_NEW_SMALL_INT(-1));
+ nlr_pop();
+ } else {
+ mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
+ }
+
+ // mp_obj_int_get_uint_checked with negative big-int (should raise exception)
+ if (nlr_push(&nlr) == 0) {
+ mp_obj_int_get_uint_checked(mp_obj_new_int_from_ll(-2));
+ nlr_pop();
+ } else {
+ mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val));
+ }
}
// warning
diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp
index 8922f9616..6aa2da31a 100644
--- a/tests/unix/extra_coverage.py.exp
+++ b/tests/unix/extra_coverage.py.exp
@@ -54,6 +54,10 @@ data
# runtime utils
TypeError: unsupported type for __abs__: 'str'
TypeError: unsupported types for __divmod__: 'str', 'str'
+1
+2
+OverflowError: overflow converting long int to machine word
+OverflowError: overflow converting long int to machine word
Warning: test
# format float
?