File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 import sys
66 sys .exit ()
77
8- extra_coverage ()
8+ data = extra_coverage ()
9+
10+ # test hashing of str/bytes that have an invalid hash
11+ print (data )
12+ print (hash (data [0 ]))
13+ print (hash (data [1 ]))
14+ print (hash (bytes (data [0 ], 'utf8' )))
15+ print (hash (str (data [1 ], 'utf8' )))
Original file line number Diff line number Diff line change @@ -35,3 +35,8 @@ ementation
353512345678
36360
37370
38+ ('0123456789', b'0123456789')
39+ 7300
40+ 7300
41+ 7300
42+ 7300
Original file line number Diff line number Diff line change 11#include <stdio.h>
22
33#include "py/obj.h"
4+ #include "py/objstr.h"
45#include "py/runtime.h"
56#include "py/repl.h"
67#include "py/mpz.h"
78
89#if defined(MICROPY_UNIX_COVERAGE )
910
11+ // str/bytes objects without a valid hash
12+ STATIC const mp_obj_str_t str_no_hash_obj = {{& mp_type_str }, 0 , 10 , (const byte * )"0123456789" };
13+ STATIC const mp_obj_str_t bytes_no_hash_obj = {{& mp_type_bytes }, 0 , 10 , (const byte * )"0123456789" };
14+
1015// function to run extra tests for things that can't be checked by scripts
1116STATIC mp_obj_t extra_coverage (void ) {
1217 // mp_printf (used by ports that don't have a native printf)
@@ -109,7 +114,9 @@ STATIC mp_obj_t extra_coverage(void) {
109114 mp_printf (& mp_plat_print , "%d\n" , mpz_as_uint_checked (& mpz , & value ));
110115 }
111116
112- return mp_const_none ;
117+ // return a tuple of data for testing on the Python side
118+ mp_obj_t items [] = {(mp_obj_t )& str_no_hash_obj , (mp_obj_t )& bytes_no_hash_obj };
119+ return mp_obj_new_tuple (MP_ARRAY_SIZE (items ), items );
113120}
114121MP_DEFINE_CONST_FUN_OBJ_0 (extra_coverage_obj , extra_coverage );
115122
You can’t perform that action at this time.
0 commit comments