@@ -98,19 +98,21 @@ macro_rules! impl_spaced_input {
9898 {
9999 fn get_cases( ctx: & CheckCtx ) -> ( impl Iterator <Item = Self >, u64 ) {
100100 let max_steps0 = iteration_count( ctx, 0 ) ;
101- // `f16` and `f32` can have exhaustive tests.
102- match total_value_count:: <Arg0 <Op >>( ) {
103- Some ( steps0) if steps0 <= max_steps0 => {
104- let iter0 = exhaustive_float( ) ;
105- let iter0 = iter0. map( |v| ( v, ) ) ;
106- ( EitherIter :: A ( iter0) , steps0)
107- }
108- _ => {
109- let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
110- let iter0 = iter0. map( |v| ( v, ) ) ;
111- ( EitherIter :: B ( iter0) , steps0)
112- }
101+
102+ // Unary tests: `f16` and `f32` may be exhaustive.
103+ if let Some ( steps0) = total_value_count:: <Arg0 <Op >>( )
104+ && steps0 <= max_steps0
105+ {
106+ let iter0 = exhaustive_float( ) ;
107+ let iter0 = iter0. map( |v| ( v, ) ) ;
108+
109+ return ( EitherIter :: A ( iter0) , steps0) ;
113110 }
111+
112+ // Non-exhaustive, sweep a subset of inputs.
113+ let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
114+ let iter0 = iter0. map( |v| ( v, ) ) ;
115+ ( EitherIter :: B ( iter0) , steps0)
114116 }
115117 }
116118
@@ -121,24 +123,29 @@ macro_rules! impl_spaced_input {
121123 fn get_cases( ctx: & CheckCtx ) -> ( impl Iterator <Item = Self >, u64 ) {
122124 let max_steps0 = iteration_count( ctx, 0 ) ;
123125 let max_steps1 = iteration_count( ctx, 1 ) ;
124- // `f16` can have exhaustive tests.
125- match total_value_count:: <Arg0 <Op >>( ) {
126- Some ( count) if count <= max_steps0 && count <= max_steps1 => {
127- let iter = exhaustive_float( ) . flat_map( |first| {
128- exhaustive_float( ) . map( move |second| ( first, second) )
129- } ) ;
130- ( EitherIter :: A ( iter) , count. strict_mul( count) )
131- }
132- _ => {
133- let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
134- let ( iter1, steps1) = logspace_steps:: <Arg1 <Op >>( ctx, 1 , max_steps1) ;
135- let iter = iter0. flat_map( move |first| {
136- iter1. clone( ) . map( move |second| ( first, second) )
137- } ) ;
138- let count = steps0. strict_mul( steps1) ;
139- ( EitherIter :: B ( iter) , count)
140- }
126+
127+ // Binary test: `f16` may be exhaustive.
128+ if let Some ( steps0) = total_value_count:: <Arg0 <Op >>( )
129+ && steps0 <= max_steps0
130+ && let Some ( steps1) = total_value_count:: <Arg1 <Op >>( )
131+ && steps1 <= max_steps1
132+ {
133+ let iter = exhaustive_float( )
134+ . flat_map( |first| exhaustive_float( ) . map( move |second| ( first, second) ) ) ;
135+ let count = steps0. strict_mul( steps1) ;
136+
137+ return ( EitherIter :: A ( iter) , count) ;
141138 }
139+
140+ // Non-exhaustive, sweep a subset of inputs.
141+ let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
142+ let ( iter1, steps1) = logspace_steps:: <Arg1 <Op >>( ctx, 1 , max_steps1) ;
143+
144+ let iter =
145+ iter0. flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) ) ;
146+ let count = steps0. strict_mul( steps1) ;
147+
148+ ( EitherIter :: B ( iter) , count)
142149 }
143150 }
144151
@@ -150,33 +157,39 @@ macro_rules! impl_spaced_input {
150157 let max_steps0 = iteration_count( ctx, 0 ) ;
151158 let max_steps1 = iteration_count( ctx, 1 ) ;
152159 let max_steps2 = iteration_count( ctx, 2 ) ;
153- // `f16` can be exhaustive tested if `LIBM_EXTENSIVE_TESTS` is incresed.
154- match total_value_count:: <Arg0 <Op >>( ) {
155- Some ( count)
156- if count <= max_steps0 && count <= max_steps1 && count <= max_steps2 =>
157- {
158- let iter = exhaustive_float( ) . flat_map( |first| {
159- exhaustive_float( ) . flat_map( move |second| {
160- exhaustive_float( ) . map( move |third| ( first, second, third) )
161- } )
162- } ) ;
163- ( EitherIter :: A ( iter) , count. checked_pow( 3 ) . unwrap( ) )
164- }
165- _ => {
166- let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
167- let ( iter1, steps1) = logspace_steps:: <Arg1 <Op >>( ctx, 1 , max_steps1) ;
168- let ( iter2, steps2) = logspace_steps:: <Arg2 <Op >>( ctx, 2 , max_steps2) ;
169-
170- let iter = iter0
171- . flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) )
172- . flat_map( move |( first, second) | {
173- iter2. clone( ) . map( move |third| ( first, second, third) )
174- } ) ;
175- let count = steps0. strict_mul( steps1) . strict_mul( steps2) ;
176-
177- ( EitherIter :: B ( iter) , count)
178- }
160+
161+ // Ternary test: `f16` may be exhaustive tested if `LIBM_EXTENSIVE_TESTS`
162+ // is incresed.
163+ if let Some ( steps0) = total_value_count:: <Arg0 <Op >>( )
164+ && steps0 <= max_steps0
165+ && let Some ( steps1) = total_value_count:: <Arg1 <Op >>( )
166+ && steps1 <= max_steps1
167+ && let Some ( steps2) = total_value_count:: <Arg2 <Op >>( )
168+ && steps2 <= max_steps2
169+ {
170+ let iter = exhaustive_float( ) . flat_map( |first| {
171+ exhaustive_float( ) . flat_map( move |second| {
172+ exhaustive_float( ) . map( move |third| ( first, second, third) )
173+ } )
174+ } ) ;
175+ let count = steps0. strict_mul( steps1) . strict_mul( steps2) ;
176+
177+ return ( EitherIter :: A ( iter) , count) ;
179178 }
179+
180+ // Non-exhaustive, sweep a subset of inputs.
181+ let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
182+ let ( iter1, steps1) = logspace_steps:: <Arg1 <Op >>( ctx, 1 , max_steps1) ;
183+ let ( iter2, steps2) = logspace_steps:: <Arg2 <Op >>( ctx, 2 , max_steps2) ;
184+
185+ let iter = iter0
186+ . flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) )
187+ . flat_map( move |( first, second) | {
188+ iter2. clone( ) . map( move |third| ( first, second, third) )
189+ } ) ;
190+ let count = steps0. strict_mul( steps1) . strict_mul( steps2) ;
191+
192+ ( EitherIter :: B ( iter) , count)
180193 }
181194 }
182195
@@ -188,27 +201,27 @@ macro_rules! impl_spaced_input {
188201 let range0 = int_range( ctx, 0 ) . unwrap_or( full_range( ) ) ;
189202 let max_steps0 = iteration_count( ctx, 0 ) ;
190203 let max_steps1 = iteration_count( ctx, 1 ) ;
191- match total_value_count:: <Arg1 <Op >>( ) {
192- Some ( count1) if count1 <= max_steps1 => {
193- let ( iter0, steps0) = linear_ints( range0, max_steps0) ;
194- let iter = iter0. flat_map( move |first| {
195- exhaustive_float( ) . map( move |second| ( first, second) )
196- } ) ;
197- let count = steps0. strict_mul( count1) ;
198- ( EitherIter :: A ( iter) , count)
199- }
200- _ => {
201- let ( iter0, steps0) = linear_ints( range0, max_steps0) ;
202- let ( iter1, steps1) = logspace_steps:: <Arg1 <Op >>( ctx, 1 , max_steps1) ;
203-
204- let iter = iter0. flat_map( move |first| {
205- iter1. clone( ) . map( move |second| ( first, second) )
206- } ) ;
207- let count = steps0. strict_mul( steps1) ;
208-
209- ( EitherIter :: B ( iter) , count)
210- }
204+
205+ if let Some ( steps1) = total_value_count:: <Arg1 <Op >>( )
206+ && steps1 <= max_steps1
207+ {
208+ let ( iter0, steps0) = linear_ints( range0, max_steps0) ;
209+ let iter = iter0. flat_map( move |first| {
210+ exhaustive_float( ) . map( move |second| ( first, second) )
211+ } ) ;
212+ let count = steps0. strict_mul( steps1) ;
213+
214+ return ( EitherIter :: A ( iter) , count) ;
211215 }
216+
217+ let ( iter0, steps0) = linear_ints( range0, max_steps0) ;
218+ let ( iter1, steps1) = logspace_steps:: <Arg1 <Op >>( ctx, 1 , max_steps1) ;
219+
220+ let iter =
221+ iter0. flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) ) ;
222+ let count = steps0. strict_mul( steps1) ;
223+
224+ ( EitherIter :: B ( iter) , count)
212225 }
213226 }
214227
@@ -220,27 +233,26 @@ macro_rules! impl_spaced_input {
220233 let max_steps0 = iteration_count( ctx, 0 ) ;
221234 let range1 = int_range( ctx, 1 ) . unwrap_or( full_range( ) ) ;
222235 let max_steps1 = iteration_count( ctx, 1 ) ;
223- match total_value_count:: <Arg0 <Op >>( ) {
224- Some ( count0) if count0 <= max_steps0 => {
225- let ( iter1, steps1) = linear_ints( range1, max_steps1) ;
226- let iter = exhaustive_float( ) . flat_map( move |first| {
227- iter1. clone( ) . map( move |second| ( first, second) )
228- } ) ;
229- let count = count0. strict_mul( steps1) ;
230- ( EitherIter :: A ( iter) , count)
231- }
232- _ => {
233- let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
234- let ( iter1, steps1) = linear_ints( range1, max_steps1) ;
235-
236- let iter = iter0. flat_map( move |first| {
237- iter1. clone( ) . map( move |second| ( first, second) )
238- } ) ;
239- let count = steps0. strict_mul( steps1) ;
240-
241- ( EitherIter :: B ( iter) , count)
242- }
236+
237+ if let Some ( steps0) = total_value_count:: <Arg0 <Op >>( )
238+ && steps0 <= max_steps0
239+ {
240+ let ( iter1, steps1) = linear_ints( range1, max_steps1) ;
241+ let iter = exhaustive_float( )
242+ . flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) ) ;
243+ let count = steps0. strict_mul( steps1) ;
244+
245+ return ( EitherIter :: A ( iter) , count) ;
243246 }
247+
248+ let ( iter0, steps0) = logspace_steps:: <Arg0 <Op >>( ctx, 0 , max_steps0) ;
249+ let ( iter1, steps1) = linear_ints( range1, max_steps1) ;
250+
251+ let iter =
252+ iter0. flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) ) ;
253+ let count = steps0. strict_mul( steps1) ;
254+
255+ ( EitherIter :: B ( iter) , count)
244256 }
245257 }
246258 } ;
@@ -262,17 +274,17 @@ macro_rules! impl_spaced_input_int {
262274 fn get_cases( ctx: & CheckCtx ) -> ( impl Iterator <Item = Self >, u64 ) {
263275 let range = int_range( ctx, 0 ) . unwrap_or( full_range( ) ) ;
264276 let max_steps0 = iteration_count( ctx, 0 ) ;
265- match total_value_count_int:: <Arg0 <Op >>( ) {
266- Some ( steps0) if steps0 <= max_steps0 => {
267- let iter0 = range. map( |v| ( v, ) ) ;
268- ( EitherIter :: A ( iter0) , steps0)
269- }
270- _ => {
271- let ( iter0, steps0) = linear_ints:: <Arg0 <Op >>( range, max_steps0) ;
272- let iter0 = iter0. map( |v| ( v, ) ) ;
273- ( EitherIter :: B ( iter0) , steps0)
274- }
277+
278+ if let Some ( steps0) = total_value_count_int:: <Arg0 <Op >>( )
279+ && steps0 <= max_steps0
280+ {
281+ let iter0 = range. map( |v| ( v, ) ) ;
282+ return ( EitherIter :: A ( iter0) , steps0) ;
275283 }
284+
285+ let ( iter0, steps0) = linear_ints:: <Arg0 <Op >>( range, max_steps0) ;
286+ let iter0 = iter0. map( |v| ( v, ) ) ;
287+ ( EitherIter :: B ( iter0) , steps0)
276288 }
277289 }
278290
@@ -285,24 +297,26 @@ macro_rules! impl_spaced_input_int {
285297 let range1 = int_range( ctx, 1 ) . unwrap_or( full_range( ) ) ;
286298 let max_steps0 = iteration_count( ctx, 0 ) ;
287299 let max_steps1 = iteration_count( ctx, 0 ) ;
288- match total_value_count_int:: <Arg0 <Op >>( ) {
289- Some ( count) if count <= max_steps0 && count < max_steps1 => {
290- let iter = range0. flat_map( move |first| {
291- range1. clone( ) . map( move |second| ( first, second) )
292- } ) ;
293- let count = count. strict_mul( count) ;
294- ( EitherIter :: A ( iter) , count)
295- }
296- _ => {
297- let ( iter0, steps0) = linear_ints:: <Arg0 <Op >>( range0, max_steps0) ;
298- let ( iter1, steps1) = linear_ints:: <Arg1 <Op >>( range1, max_steps1) ;
299- let iter = iter0. flat_map( move |first| {
300- iter1. clone( ) . map( move |second| ( first, second) )
301- } ) ;
302- let count = steps0. strict_mul( steps1) ;
303- ( EitherIter :: B ( iter) , count)
304- }
300+
301+ if let Some ( steps0) = total_value_count_int:: <Arg0 <Op >>( )
302+ && steps0 <= max_steps0
303+ && let Some ( steps1) = total_value_count_int:: <Arg0 <Op >>( )
304+ && steps1 <= max_steps1
305+ {
306+ let iter = range0
307+ . flat_map( move |first| range1. clone( ) . map( move |second| ( first, second) ) ) ;
308+ let count = steps0. strict_mul( steps1) ;
309+
310+ return ( EitherIter :: A ( iter) , count) ;
305311 }
312+
313+ let ( iter0, steps0) = linear_ints:: <Arg0 <Op >>( range0, max_steps0) ;
314+ let ( iter1, steps1) = linear_ints:: <Arg1 <Op >>( range1, max_steps1) ;
315+ let iter =
316+ iter0. flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) ) ;
317+ let count = steps0. strict_mul( steps1) ;
318+
319+ ( EitherIter :: B ( iter) , count)
306320 }
307321 }
308322 } ;
@@ -318,24 +332,25 @@ macro_rules! impl_spaced_input_int {
318332 let range1 = int_range( ctx, 1 ) . unwrap_or( full_range( ) ) ;
319333 let max_steps0 = iteration_count( ctx, 0 ) ;
320334 let max_steps1 = iteration_count( ctx, 0 ) ;
321- match total_value_count_int:: <Arg0 <Op >>( ) {
322- Some ( count) if count <= max_steps0 && count < max_steps1 => {
323- let iter = range0. flat_map( move |first| {
324- range1. clone( ) . map( move |second| ( first, second) )
325- } ) ;
326- let count = count. strict_mul( count) ;
327- ( EitherIter :: A ( iter) , count)
328- }
329- _ => {
330- let ( iter0, steps0) = linear_ints:: <Arg0 <Op >>( range0, max_steps0) ;
331- let ( iter1, steps1) = linear_ints:: <Arg1 <Op >>( range1, max_steps1) ;
332- let iter = iter0. flat_map( move |first| {
333- iter1. clone( ) . map( move |second| ( first, second) )
334- } ) ;
335- let count = steps0. strict_mul( steps1) ;
336- ( EitherIter :: B ( iter) , count)
337- }
335+
336+ if let Some ( steps0) = total_value_count_int:: <Arg0 <Op >>( )
337+ && steps0 <= max_steps0
338+ && let Some ( steps1) = total_value_count_int:: <Arg0 <Op >>( )
339+ && steps1 <= max_steps1
340+ {
341+ let iter = range0
342+ . flat_map( move |first| range1. clone( ) . map( move |second| ( first, second) ) ) ;
343+ let count = steps0. strict_mul( steps1) ;
344+
345+ return ( EitherIter :: A ( iter) , count) ;
338346 }
347+
348+ let ( iter0, steps0) = linear_ints:: <Arg0 <Op >>( range0, max_steps0) ;
349+ let ( iter1, steps1) = linear_ints:: <Arg1 <Op >>( range1, max_steps1) ;
350+ let iter =
351+ iter0. flat_map( move |first| iter1. clone( ) . map( move |second| ( first, second) ) ) ;
352+ let count = steps0. strict_mul( steps1) ;
353+ ( EitherIter :: B ( iter) , count)
339354 }
340355 }
341356 } ;
0 commit comments