Skip to content

Commit 75aa7be

Browse files
flowergrassdpgeorge
authored andcommitted
tests/unix: Improve runtime_utils.c test coverage.
1 parent b7024f0 commit 75aa7be

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

tests/unix/extra_coverage.py.exp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ ementation
3535
12345678
3636
0
3737
0
38+
# runtime utils
39+
TypeError: can't convert str to int
40+
TypeError: unsupported types for : 'str', 'str'
3841
('0123456789', b'0123456789')
3942
7300
4043
7300

unix/coverage.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "py/runtime.h"
66
#include "py/repl.h"
77
#include "py/mpz.h"
8+
#include "py/builtin.h"
89

910
#if defined(MICROPY_UNIX_COVERAGE)
1011

@@ -114,6 +115,21 @@ STATIC mp_obj_t extra_coverage(void) {
114115
mp_printf(&mp_plat_print, "%d\n", mpz_as_uint_checked(&mpz, &value));
115116
}
116117

118+
// runtime utils
119+
{
120+
mp_printf(&mp_plat_print, "# runtime utils\n");
121+
122+
// call mp_call_function_1_protected
123+
mp_call_function_1_protected(MP_OBJ_FROM_PTR(&mp_builtin_abs_obj), MP_OBJ_NEW_SMALL_INT(1));
124+
// call mp_call_function_1_protected with invalid args
125+
mp_call_function_1_protected(MP_OBJ_FROM_PTR(&mp_builtin_abs_obj), mp_obj_new_str("abc", 3, false));
126+
127+
// call mp_call_function_2_protected
128+
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));
129+
// call mp_call_function_2_protected with invalid args
130+
mp_call_function_2_protected(MP_OBJ_FROM_PTR(&mp_builtin_divmod_obj), mp_obj_new_str("abc", 3, false), mp_obj_new_str("abc", 3, false));
131+
}
132+
117133
// return a tuple of data for testing on the Python side
118134
mp_obj_t items[] = {(mp_obj_t)&str_no_hash_obj, (mp_obj_t)&bytes_no_hash_obj};
119135
return mp_obj_new_tuple(MP_ARRAY_SIZE(items), items);

0 commit comments

Comments
 (0)