diff options
author | Damien George <damien.p.george@gmail.com> | 2016-09-02 15:07:42 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-09-02 15:07:42 +1000 |
commit | 58f386135813ab6e55641bec6eae32cc0fd35115 (patch) | |
tree | 8af898867c765aefa46e4f3ffaf16bef85e6227c /unix | |
parent | 5f3bda422a18d49fb282a93968b658c568343b7d (diff) | |
download | micropython-58f386135813ab6e55641bec6eae32cc0fd35115.tar.gz micropython-58f386135813ab6e55641bec6eae32cc0fd35115.zip |
tests/unix/extra_coverage: Add test for str/bytes with invalid hash.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/coverage.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/unix/coverage.c b/unix/coverage.c index ce1da50e2f..c84a653f75 100644 --- a/unix/coverage.c +++ b/unix/coverage.c @@ -1,12 +1,17 @@ #include <stdio.h> #include "py/obj.h" +#include "py/objstr.h" #include "py/runtime.h" #include "py/repl.h" #include "py/mpz.h" #if defined(MICROPY_UNIX_COVERAGE) +// str/bytes objects without a valid hash +STATIC const mp_obj_str_t str_no_hash_obj = {{&mp_type_str}, 0, 10, (const byte*)"0123456789"}; +STATIC const mp_obj_str_t bytes_no_hash_obj = {{&mp_type_bytes}, 0, 10, (const byte*)"0123456789"}; + // function to run extra tests for things that can't be checked by scripts STATIC mp_obj_t extra_coverage(void) { // mp_printf (used by ports that don't have a native printf) @@ -109,7 +114,9 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "%d\n", mpz_as_uint_checked(&mpz, &value)); } - return mp_const_none; + // return a tuple of data for testing on the Python side + mp_obj_t items[] = {(mp_obj_t)&str_no_hash_obj, (mp_obj_t)&bytes_no_hash_obj}; + return mp_obj_new_tuple(MP_ARRAY_SIZE(items), items); } MP_DEFINE_CONST_FUN_OBJ_0(extra_coverage_obj, extra_coverage); |