diff options
-rw-r--r-- | ports/unix/coverage.c | 33 | ||||
-rw-r--r-- | tests/unix/extra_coverage.py.exp | 6 |
2 files changed, 39 insertions, 0 deletions
diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 6b6b89285..25376edc0 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -262,6 +262,39 @@ STATIC mp_obj_t extra_coverage(void) { mpz_set_from_int(&mpz, 1); mpz_shl_inpl(&mpz, &mpz, 70); mp_printf(&mp_plat_print, "%d\n", mpz_as_uint_checked(&mpz, &value)); + + // mpz_set_from_float with inf as argument + mpz_set_from_float(&mpz, 1.0 / 0.0); + mpz_as_uint_checked(&mpz, &value); + mp_printf(&mp_plat_print, "%d\n", (int)value); + + // mpz_set_from_float with 0 as argument + mpz_set_from_float(&mpz, 0); + mpz_as_uint_checked(&mpz, &value); + mp_printf(&mp_plat_print, "%d\n", (int)value); + + // mpz_set_from_float with 0<x<1 as argument + mpz_set_from_float(&mpz, 1e-10); + mpz_as_uint_checked(&mpz, &value); + mp_printf(&mp_plat_print, "%d\n", (int)value); + + // mpz_set_from_float with 1<=x<2 as argument + mpz_set_from_float(&mpz, 1.5); + mpz_as_uint_checked(&mpz, &value); + mp_printf(&mp_plat_print, "%d\n", (int)value); + + // mpz_set_from_float with 2<x as argument + mpz_set_from_float(&mpz, 12345); + mpz_as_uint_checked(&mpz, &value); + mp_printf(&mp_plat_print, "%d\n", (int)value); + + // mpz_mul_inpl with dest==rhs, lhs!=rhs + mpz_t mpz2; + mpz_set_from_int(&mpz, 2); + mpz_init_from_int(&mpz2, 3); + mpz_mul_inpl(&mpz, &mpz2, &mpz); + mpz_as_uint_checked(&mpz, &value); + mp_printf(&mp_plat_print, "%d\n", (int)value); } // runtime utils diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 8a2c6aea9..71b6867ca 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -41,6 +41,12 @@ data 12345678 0 0 +0 +0 +0 +1 +12345 +6 # runtime utils TypeError: unsupported type for __abs__: 'str' TypeError: unsupported types for __divmod__: 'str', 'str' |