@@ -185,6 +185,8 @@ static void pairheap_test(size_t nops, int *ops) {
185185 mp_printf (& mp_plat_print , "\n" );
186186}
187187
188+ // CIRCUITPY-CHANGE: not turned on in CircuitPython
189+ #if MICROPY_SCHEDULER_STATIC_NODES
188190static mp_sched_node_t mp_coverage_sched_node ;
189191static bool coverage_sched_function_continue ;
190192
@@ -196,6 +198,7 @@ static void coverage_sched_function(mp_sched_node_t *node) {
196198 mp_sched_schedule_node (& mp_coverage_sched_node , coverage_sched_function );
197199 }
198200}
201+ #endif
199202
200203// function to run extra tests for things that can't be checked by scripts
201204static mp_obj_t extra_coverage (void ) {
@@ -589,6 +592,22 @@ static mp_obj_t extra_coverage(void) {
589592 mp_obj_print_exception (& mp_plat_print , MP_OBJ_FROM_PTR (nlr .ret_val ));
590593 }
591594
595+ // mp_obj_get_uint from a non-int object (should raise exception)
596+ if (nlr_push (& nlr ) == 0 ) {
597+ mp_obj_get_uint (mp_const_none );
598+ nlr_pop ();
599+ } else {
600+ mp_obj_print_exception (& mp_plat_print , MP_OBJ_FROM_PTR (nlr .ret_val ));
601+ }
602+
603+ // mp_obj_int_get_ll from a non-int object (should raise exception)
604+ if (nlr_push (& nlr ) == 0 ) {
605+ mp_obj_get_ll (mp_const_none );
606+ nlr_pop ();
607+ } else {
608+ mp_obj_print_exception (& mp_plat_print , MP_OBJ_FROM_PTR (nlr .ret_val ));
609+ }
610+
592611 // call mp_obj_new_exception_args (it's a part of the public C API and not used in the core)
593612 mp_obj_print_exception (& mp_plat_print , mp_obj_new_exception_args (& mp_type_ValueError , 0 , NULL ));
594613 }
@@ -598,26 +617,6 @@ static mp_obj_t extra_coverage(void) {
598617 mp_emitter_warning (MP_PASS_CODE_SIZE , "test" );
599618 }
600619
601- // format float
602- {
603- mp_printf (& mp_plat_print , "# format float\n" );
604-
605- // format with inadequate buffer size
606- char buf [5 ];
607- mp_format_float (1 , buf , sizeof (buf ), 'g' , 0 , '+' );
608- mp_printf (& mp_plat_print , "%s\n" , buf );
609-
610- // format with just enough buffer so that precision must be
611- // set from 0 to 1 twice
612- char buf2 [8 ];
613- mp_format_float (1 , buf2 , sizeof (buf2 ), 'g' , 0 , '+' );
614- mp_printf (& mp_plat_print , "%s\n" , buf2 );
615-
616- // format where precision is trimmed to avoid buffer overflow
617- mp_format_float (1 , buf2 , sizeof (buf2 ), 'e' , 0 , '+' );
618- mp_printf (& mp_plat_print , "%s\n" , buf2 );
619- }
620-
621620 // binary
622621 {
623622 mp_printf (& mp_plat_print , "# binary\n" );
@@ -641,14 +640,26 @@ static mp_obj_t extra_coverage(void) {
641640 fun_bc .context = & context ;
642641 fun_bc .child_table = NULL ;
643642 fun_bc .bytecode = (const byte * )"\x01" ; // just needed for n_state
643+ #if MICROPY_PY_SYS_SETTRACE
644+ struct _mp_raw_code_t rc = {};
645+ fun_bc .rc = & rc ;
646+ #endif
644647 mp_code_state_t * code_state = m_new_obj_var (mp_code_state_t , state , mp_obj_t , 1 );
645648 code_state -> fun_bc = & fun_bc ;
646649 code_state -> ip = (const byte * )"\x00" ; // just needed for an invalid opcode
647650 code_state -> sp = & code_state -> state [0 ];
648651 code_state -> exc_sp_idx = 0 ;
649652 code_state -> old_globals = NULL ;
653+ #if MICROPY_STACKLESS
654+ code_state -> prev = NULL ;
655+ #endif
656+ #if MICROPY_PY_SYS_SETTRACE
657+ code_state -> prev_state = NULL ;
658+ code_state -> frame = NULL ;
659+ #endif
660+
650661 mp_vm_return_kind_t ret = mp_execute_bytecode (code_state , MP_OBJ_NULL );
651- mp_printf (& mp_plat_print , "%d %d\n" , ret , mp_obj_get_type (code_state -> state [0 ]) == & mp_type_NotImplementedError );
662+ mp_printf (& mp_plat_print , "%d %d\n" , ( int ) ret , mp_obj_get_type (code_state -> state [0 ]) == & mp_type_NotImplementedError );
652663 }
653664
654665 // scheduler
@@ -705,9 +716,25 @@ static mp_obj_t extra_coverage(void) {
705716 mp_obj_print_exception (& mp_plat_print , MP_OBJ_FROM_PTR (nlr .ret_val ));
706717 }
707718 mp_handle_pending (true);
719+
720+ // CIRCUITPY-CHANGE: not turned on in CircuitPython
721+ #if MICROPY_SCHEDULER_STATIC_NODES
722+ coverage_sched_function_continue = true;
723+ mp_sched_schedule_node (& mp_coverage_sched_node , coverage_sched_function );
724+ for (int i = 0 ; i < 3 ; ++ i ) {
725+ mp_printf (& mp_plat_print , "loop\n" );
726+ mp_handle_pending (true);
727+ }
728+ // Clear this flag to prevent the function scheduling itself again
729+ coverage_sched_function_continue = false;
730+ // Will only run the first time through this loop, then not scheduled again
731+ for (int i = 0 ; i < 3 ; ++ i ) {
732+ mp_handle_pending (true);
733+ }
734+ #endif
708735 }
709736
710- // CIRCUITPY-CHANGE: ringbuf is different
737+ // CIRCUITPY-CHANGE: ringbuf is quite different
711738 // ringbuf
712739 {
713740 #define RINGBUF_SIZE 99
@@ -719,7 +746,7 @@ static mp_obj_t extra_coverage(void) {
719746 mp_printf (& mp_plat_print , "# ringbuf\n" );
720747
721748 // Single-byte put/get with empty ringbuf.
722- mp_printf (& mp_plat_print , "%d %d\n" , (int )ringbuf_free (& ringbuf ), (int )ringbuf_num_filled (& ringbuf ));
749+ mp_printf (& mp_plat_print , "%d %d\n" , (int )ringbuf_num_empty (& ringbuf ), (int )ringbuf_num_filled (& ringbuf ));
723750 ringbuf_put (& ringbuf , 22 );
724751 mp_printf (& mp_plat_print , "%d %d\n" , (int )ringbuf_num_empty (& ringbuf ), (int )ringbuf_num_filled (& ringbuf ));
725752 mp_printf (& mp_plat_print , "%d\n" , ringbuf_get (& ringbuf ));
0 commit comments