diff --git a/library/compiler-builtins/libm-test/src/generate/spaced.rs b/library/compiler-builtins/libm-test/src/generate/spaced.rs index a825fe4c323b..b6bc4e9ac5d5 100644 --- a/library/compiler-builtins/libm-test/src/generate/spaced.rs +++ b/library/compiler-builtins/libm-test/src/generate/spaced.rs @@ -66,14 +66,14 @@ fn size_hint(&self) -> (usize, Option) { /// Gets the total number of possible values, returning `None` if that number doesn't fit in a /// `u64`. -fn value_count() -> Option +fn total_value_count() -> Option where u64: TryFrom, { - value_count_int::() + total_value_count_int::() } -fn value_count_int() -> Option +fn total_value_count_int() -> Option where u64: TryFrom, { @@ -83,7 +83,7 @@ fn value_count_int() -> Option } /// Returns an iterator of every possible value of type `F`. -fn all_values() -> impl Iterator +fn exhaustive_float() -> impl Iterator where RangeInclusive: Iterator, { @@ -99,9 +99,9 @@ impl SpacedInput for ($fty,) fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let max_steps0 = iteration_count(ctx, 0); // `f16` and `f32` can have exhaustive tests. - match value_count::>() { + match total_value_count::>() { Some(steps0) if steps0 <= max_steps0 => { - let iter0 = all_values(); + let iter0 = exhaustive_float(); let iter0 = iter0.map(|v| (v,)); (EitherIter::A(iter0), steps0) } @@ -122,10 +122,11 @@ fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let max_steps0 = iteration_count(ctx, 0); let max_steps1 = iteration_count(ctx, 1); // `f16` can have exhaustive tests. - match value_count::>() { + match total_value_count::>() { Some(count) if count <= max_steps0 && count <= max_steps1 => { - let iter = all_values() - .flat_map(|first| all_values().map(move |second| (first, second))); + let iter = exhaustive_float().flat_map(|first| { + exhaustive_float().map(move |second| (first, second)) + }); (EitherIter::A(iter), count.checked_mul(count).unwrap()) } _ => { @@ -150,13 +151,13 @@ fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let max_steps1 = iteration_count(ctx, 1); let max_steps2 = iteration_count(ctx, 2); // `f16` can be exhaustive tested if `LIBM_EXTENSIVE_TESTS` is incresed. - match value_count::>() { + match total_value_count::>() { Some(count) if count <= max_steps0 && count <= max_steps1 && count <= max_steps2 => { - let iter = all_values().flat_map(|first| { - all_values().flat_map(move |second| { - all_values().map(move |third| (first, second, third)) + let iter = exhaustive_float().flat_map(|first| { + exhaustive_float().flat_map(move |second| { + exhaustive_float().map(move |third| (first, second, third)) }) }); (EitherIter::A(iter), count.checked_pow(3).unwrap()) @@ -191,11 +192,12 @@ fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let range0 = int_range(ctx, 0).unwrap_or(full_range()); let max_steps0 = iteration_count(ctx, 0); let max_steps1 = iteration_count(ctx, 1); - match value_count::>() { + match total_value_count::>() { Some(count1) if count1 <= max_steps1 => { let (iter0, steps0) = linear_ints(range0, max_steps0); - let iter = iter0 - .flat_map(move |first| all_values().map(move |second| (first, second))); + let iter = iter0.flat_map(move |first| { + exhaustive_float().map(move |second| (first, second)) + }); (EitherIter::A(iter), steps0.checked_mul(count1).unwrap()) } _ => { @@ -221,10 +223,10 @@ fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let max_steps0 = iteration_count(ctx, 0); let range1 = int_range(ctx, 1).unwrap_or(full_range()); let max_steps1 = iteration_count(ctx, 1); - match value_count::>() { + match total_value_count::>() { Some(count0) if count0 <= max_steps0 => { let (iter1, steps1) = linear_ints(range1, max_steps1); - let iter = all_values().flat_map(move |first| { + let iter = exhaustive_float().flat_map(move |first| { iter1.clone().map(move |second| (first, second)) }); (EitherIter::A(iter), count0.checked_mul(steps1).unwrap()) @@ -262,7 +264,7 @@ impl SpacedInput for ($ity,) fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let range = int_range(ctx, 0).unwrap_or(full_range()); let max_steps0 = iteration_count(ctx, 0); - match value_count_int::>() { + match total_value_count_int::>() { Some(steps0) if steps0 <= max_steps0 => { let iter0 = range.map(|v| (v,)); (EitherIter::A(iter0), steps0) @@ -285,7 +287,7 @@ fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let range1 = int_range(ctx, 1).unwrap_or(full_range()); let max_steps0 = iteration_count(ctx, 0); let max_steps1 = iteration_count(ctx, 0); - match value_count_int::>() { + match total_value_count_int::>() { Some(count) if count <= max_steps0 && count < max_steps1 => { let iter = range0.flat_map(move |first| { range1.clone().map(move |second| (first, second)) @@ -317,7 +319,7 @@ fn get_cases(ctx: &CheckCtx) -> (impl Iterator, u64) { let range1 = int_range(ctx, 1).unwrap_or(full_range()); let max_steps0 = iteration_count(ctx, 0); let max_steps1 = iteration_count(ctx, 0); - match value_count_int::>() { + match total_value_count_int::>() { Some(count) if count <= max_steps0 && count < max_steps1 => { let iter = range0.flat_map(move |first| { range1.clone().map(move |second| (first, second))