@@ -62,6 +62,8 @@ macro_rules! f32_f32 {
62
62
63
63
extern crate libm;
64
64
65
+ use std::panic;
66
+
65
67
#[test]
66
68
fn {0}() {{
67
69
const CASES: &[(u32, u32)] = &[
@@ -71,16 +73,23 @@ macro_rules! f32_f32 {
71
73
for case in CASES {{
72
74
let (inp, expected) = *case;
73
75
74
- let outf = libm::{0}(f32::from_bits(inp));
75
- let outi = outf.to_bits();
76
-
77
- if !((outf.is_nan() && f32::from_bits(expected).is_nan()) ||
78
- libm::_eqf(outi, expected)) {{
76
+ if let Ok(outf) =
77
+ panic::catch_unwind(|| libm::{0}(f32::from_bits(inp)))
78
+ {{
79
+ let outi = outf.to_bits();
80
+
81
+ if !((outf.is_nan() && f32::from_bits(expected).is_nan())
82
+ || libm::_eqf(outi, expected))
83
+ {{
84
+ panic!(
85
+ \" input: {{}}, output: {{}}, expected: {{}}\" ,
86
+ inp, outi, expected,
87
+ );
88
+ }}
89
+ }} else {{
79
90
panic!(
80
- \" input: {{}}, output: {{}}, expected: {{}}\" ,
81
- inp,
82
- outi,
83
- expected,
91
+ \" input: {{}}, output: PANIC, expected: {{}}\" ,
92
+ inp, expected,
84
93
);
85
94
}}
86
95
}}
@@ -124,6 +133,8 @@ macro_rules! f32f32_f32 {
124
133
125
134
extern crate libm;
126
135
136
+ use std::panic;
137
+
127
138
#[test]
128
139
fn {0}() {{
129
140
const CASES: &[((u32, u32), u32)] = &[
@@ -133,15 +144,25 @@ macro_rules! f32f32_f32 {
133
144
for case in CASES {{
134
145
let ((i1, i2), expected) = *case;
135
146
136
- let outf = libm::{0}(f32::from_bits(i1), f32::from_bits(i2));
137
- let outi = outf.to_bits();
138
-
139
- if !((outf.is_nan() && f32::from_bits(expected).is_nan()) ||
140
- libm::_eqf(outi, expected)) {{
147
+ if let Ok(outf) = panic::catch_unwind(|| {{
148
+ libm::{0}(f32::from_bits(i1), f32::from_bits(i2))
149
+ }}) {{
150
+ let outi = outf.to_bits();
151
+
152
+ if !((outf.is_nan() && f32::from_bits(expected).is_nan())
153
+ || libm::_eqf(outi, expected))
154
+ {{
155
+ panic!(
156
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
157
+ (i1, i2),
158
+ outi,
159
+ expected,
160
+ );
161
+ }}
162
+ }} else {{
141
163
panic!(
142
- \" input: {{:?}}, output: {{}} , expected: {{}}\" ,
164
+ \" input: {{:?}}, output: PANIC , expected: {{}}\" ,
143
165
(i1, i2),
144
- outi,
145
166
expected,
146
167
);
147
168
}}
@@ -188,6 +209,8 @@ macro_rules! f32f32f32_f32 {
188
209
189
210
extern crate libm;
190
211
212
+ use std::panic;
213
+
191
214
#[test]
192
215
fn {0}() {{
193
216
const CASES: &[((u32, u32, u32), u32)] = &[
@@ -197,19 +220,29 @@ macro_rules! f32f32f32_f32 {
197
220
for case in CASES {{
198
221
let ((i1, i2, i3), expected) = *case;
199
222
200
- let outf = libm::{0}(
201
- f32::from_bits(i1),
202
- f32::from_bits(i2),
203
- f32::from_bits(i3),
204
- );
205
- let outi = outf.to_bits();
206
-
207
- if !((outf.is_nan() && f32::from_bits(expected).is_nan()) ||
208
- libm::_eqf(outi, expected)) {{
223
+ if let Ok(outf) = panic::catch_unwind(|| {{
224
+ libm::{0}(
225
+ f32::from_bits(i1),
226
+ f32::from_bits(i2),
227
+ f32::from_bits(i3),
228
+ )
229
+ }}) {{
230
+ let outi = outf.to_bits();
231
+
232
+ if !((outf.is_nan() && f32::from_bits(expected).is_nan())
233
+ || libm::_eqf(outi, expected))
234
+ {{
235
+ panic!(
236
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
237
+ (i1, i2, i3),
238
+ outi,
239
+ expected,
240
+ );
241
+ }}
242
+ }} else {{
209
243
panic!(
210
- \" input: {{:?}}, output: {{}} , expected: {{}}\" ,
244
+ \" input: {{:?}}, output: PANIC , expected: {{}}\" ,
211
245
(i1, i2, i3),
212
- outi,
213
246
expected,
214
247
);
215
248
}}
@@ -253,6 +286,8 @@ macro_rules! f32i32_f32 {
253
286
254
287
extern crate libm;
255
288
289
+ use std::panic;
290
+
256
291
#[test]
257
292
fn {0}() {{
258
293
const CASES: &[((u32, i16), u32)] = &[
@@ -262,15 +297,25 @@ macro_rules! f32i32_f32 {
262
297
for case in CASES {{
263
298
let ((i1, i2), expected) = *case;
264
299
265
- let outf = libm::{0}(f32::from_bits(i1), i2 as i32);
266
- let outi = outf.to_bits();
267
-
268
- if !((outf.is_nan() && f32::from_bits(expected).is_nan()) ||
269
- libm::_eqf(outi, expected)) {{
300
+ if let Ok(outf) = panic::catch_unwind(|| {{
301
+ libm::{0}(f32::from_bits(i1), i2 as i32)
302
+ }}) {{
303
+ let outi = outf.to_bits();
304
+
305
+ if !((outf.is_nan() && f32::from_bits(expected).is_nan())
306
+ || libm::_eqf(outi, expected))
307
+ {{
308
+ panic!(
309
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
310
+ (i1, i2),
311
+ outi,
312
+ expected,
313
+ );
314
+ }}
315
+ }} else {{
270
316
panic!(
271
- \" input: {{:?}}, output: {{}} , expected: {{}}\" ,
317
+ \" input: {{:?}}, output: PANIC , expected: {{}}\" ,
272
318
(i1, i2),
273
- outi,
274
319
expected,
275
320
);
276
321
}}
@@ -314,6 +359,8 @@ macro_rules! f64_f64 {
314
359
315
360
extern crate libm;
316
361
362
+ use std::panic;
363
+
317
364
#[test]
318
365
fn {0}() {{
319
366
const CASES: &[(u64, u64)] = &[
@@ -323,15 +370,25 @@ macro_rules! f64_f64 {
323
370
for case in CASES {{
324
371
let (inp, expected) = *case;
325
372
326
- let outf = libm::{0}(f64::from_bits(inp));
327
- let outi = outf.to_bits();
328
-
329
- if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
330
- libm::_eq(outi, expected)) {{
373
+ if let Ok(outf) = panic::catch_unwind(|| {{
374
+ libm::{0}(f64::from_bits(inp))
375
+ }}) {{
376
+ let outi = outf.to_bits();
377
+
378
+ if !((outf.is_nan() && f64::from_bits(expected).is_nan())
379
+ || libm::_eq(outi, expected))
380
+ {{
381
+ panic!(
382
+ \" input: {{}}, output: {{}}, expected: {{}}\" ,
383
+ inp,
384
+ outi,
385
+ expected,
386
+ );
387
+ }}
388
+ }} else {{
331
389
panic!(
332
- \" input: {{}}, output: {{}} , expected: {{}}\" ,
390
+ \" input: {{}}, output: PANIC , expected: {{}}\" ,
333
391
inp,
334
- outi,
335
392
expected,
336
393
);
337
394
}}
@@ -376,6 +433,8 @@ macro_rules! f64f64_f64 {
376
433
377
434
extern crate libm;
378
435
436
+ use std::panic;
437
+
379
438
#[test]
380
439
fn {0}() {{
381
440
const CASES: &[((u64, u64), u64)] = &[
@@ -385,15 +444,24 @@ macro_rules! f64f64_f64 {
385
444
for case in CASES {{
386
445
let ((i1, i2), expected) = *case;
387
446
388
- let outf = libm::{0}(f64::from_bits(i1), f64::from_bits(i2));
389
- let outi = outf.to_bits();
390
-
391
- if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
392
- libm::_eq(outi, expected)) {{
447
+ if let Ok(outf) = panic::catch_unwind(|| {{
448
+ libm::{0}(f64::from_bits(i1), f64::from_bits(i2))
449
+ }}) {{
450
+ let outi = outf.to_bits();
451
+
452
+ if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
453
+ libm::_eq(outi, expected)) {{
454
+ panic!(
455
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
456
+ (i1, i2),
457
+ outi,
458
+ expected,
459
+ );
460
+ }}
461
+ }} else {{
393
462
panic!(
394
- \" input: {{:?}}, output: {{}} , expected: {{}}\" ,
463
+ \" input: {{:?}}, output: PANIC , expected: {{}}\" ,
395
464
(i1, i2),
396
- outi,
397
465
expected,
398
466
);
399
467
}}
@@ -440,6 +508,8 @@ macro_rules! f64f64f64_f64 {
440
508
441
509
extern crate libm;
442
510
511
+ use std::panic;
512
+
443
513
#[test]
444
514
fn {0}() {{
445
515
const CASES: &[((u64, u64, u64), u64)] = &[
@@ -449,19 +519,29 @@ macro_rules! f64f64f64_f64 {
449
519
for case in CASES {{
450
520
let ((i1, i2, i3), expected) = *case;
451
521
452
- let outf = libm::{0}(
453
- f64::from_bits(i1),
454
- f64::from_bits(i2),
455
- f64::from_bits(i3),
456
- );
457
- let outi = outf.to_bits();
458
-
459
- if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
460
- libm::_eq(outi, expected)) {{
522
+ if let Ok(outf) = panic::catch_unwind(|| {{
523
+ libm::{0}(
524
+ f64::from_bits(i1),
525
+ f64::from_bits(i2),
526
+ f64::from_bits(i3),
527
+ )
528
+ }}) {{
529
+ let outi = outf.to_bits();
530
+
531
+ if !((outf.is_nan() && f64::from_bits(expected).is_nan())
532
+ || libm::_eq(outi, expected))
533
+ {{
534
+ panic!(
535
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
536
+ (i1, i2, i3),
537
+ outi,
538
+ expected,
539
+ );
540
+ }}
541
+ }} else {{
461
542
panic!(
462
- \" input: {{:?}}, output: {{}} , expected: {{}}\" ,
543
+ \" input: {{:?}}, output: PANIC , expected: {{}}\" ,
463
544
(i1, i2, i3),
464
- outi,
465
545
expected,
466
546
);
467
547
}}
@@ -505,6 +585,8 @@ macro_rules! f64i32_f64 {
505
585
506
586
extern crate libm;
507
587
588
+ use std::panic;
589
+
508
590
#[test]
509
591
fn {0}() {{
510
592
const CASES: &[((u64, i16), u64)] = &[
@@ -514,15 +596,24 @@ macro_rules! f64i32_f64 {
514
596
for case in CASES {{
515
597
let ((i1, i2), expected) = *case;
516
598
517
- let outf = libm::{0}(f64::from_bits(i1), i2 as i32);
518
- let outi = outf.to_bits();
519
-
520
- if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
521
- libm::_eq(outi, expected)) {{
599
+ if let Ok(outf) = panic::catch_unwind(|| {{
600
+ libm::{0}(f64::from_bits(i1), i2 as i32)
601
+ }}) {{
602
+ let outi = outf.to_bits();
603
+
604
+ if !((outf.is_nan() && f64::from_bits(expected).is_nan()) ||
605
+ libm::_eq(outi, expected)) {{
606
+ panic!(
607
+ \" input: {{:?}}, output: {{}}, expected: {{}}\" ,
608
+ (i1, i2),
609
+ outi,
610
+ expected,
611
+ );
612
+ }}
613
+ }} else {{
522
614
panic!(
523
- \" input: {{:?}}, output: {{}} , expected: {{}}\" ,
615
+ \" input: {{:?}}, output: PANIC , expected: {{}}\" ,
524
616
(i1, i2),
525
- outi,
526
617
expected,
527
618
);
528
619
}}
0 commit comments