@@ -257,22 +257,22 @@ fn not_nan32_fail_when_constructing_with_nan() {
257
257
#[ test]
258
258
fn not_nan32_calculate_correctly ( ) {
259
259
assert_eq ! ( * ( not_nan( 5.0f32 ) + not_nan( 4.0f32 ) ) , 5.0f32 + 4.0f32 ) ;
260
- assert_eq ! ( * ( not_nan( 5.0f32 ) + 4.0f32 ) , 5.0f32 + 4.0f32 ) ;
260
+ assert_eq ! ( not_nan( 5.0f32 ) + 4.0f32 , 5.0f32 + 4.0f32 ) ;
261
261
assert_eq ! ( * ( not_nan( 5.0f32 ) - not_nan( 4.0f32 ) ) , 5.0f32 - 4.0f32 ) ;
262
- assert_eq ! ( * ( not_nan( 5.0f32 ) - 4.0f32 ) , 5.0f32 - 4.0f32 ) ;
262
+ assert_eq ! ( not_nan( 5.0f32 ) - 4.0f32 , 5.0f32 - 4.0f32 ) ;
263
263
assert_eq ! ( * ( not_nan( 5.0f32 ) * not_nan( 4.0f32 ) ) , 5.0f32 * 4.0f32 ) ;
264
- assert_eq ! ( * ( not_nan( 5.0f32 ) * 4.0f32 ) , 5.0f32 * 4.0f32 ) ;
264
+ assert_eq ! ( not_nan( 5.0f32 ) * 4.0f32 , 5.0f32 * 4.0f32 ) ;
265
265
assert_eq ! ( * ( not_nan( 8.0f32 ) / not_nan( 4.0f32 ) ) , 8.0f32 / 4.0f32 ) ;
266
- assert_eq ! ( * ( not_nan( 8.0f32 ) / 4.0f32 ) , 8.0f32 / 4.0f32 ) ;
266
+ assert_eq ! ( not_nan( 8.0f32 ) / 4.0f32 , 8.0f32 / 4.0f32 ) ;
267
267
assert_eq ! ( * ( not_nan( 8.0f32 ) % not_nan( 4.0f32 ) ) , 8.0f32 % 4.0f32 ) ;
268
- assert_eq ! ( * ( not_nan( 8.0f32 ) % 4.0f32 ) , 8.0f32 % 4.0f32 ) ;
268
+ assert_eq ! ( not_nan( 8.0f32 ) % 4.0f32 , 8.0f32 % 4.0f32 ) ;
269
269
assert_eq ! ( * ( -not_nan( 1.0f32 ) ) , -1.0f32 ) ;
270
270
271
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f32 ) + f32 :: NAN ) . is_err ( ) ) ;
272
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f32 ) - f32 :: NAN ) . is_err ( ) ) ;
273
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f32 ) * f32 :: NAN ) . is_err ( ) ) ;
274
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f32 ) / f32 :: NAN ) . is_err ( ) ) ;
275
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f32 ) % f32 :: NAN ) . is_err ( ) ) ;
271
+ assert ! ( f32 :: is_nan ( not_nan( 0.0f32 ) + f32 :: NAN ) ) ;
272
+ assert ! ( f32 :: is_nan ( not_nan( 0.0f32 ) - f32 :: NAN ) ) ;
273
+ assert ! ( f32 :: is_nan ( not_nan( 0.0f32 ) * f32 :: NAN ) ) ;
274
+ assert ! ( f32 :: is_nan ( not_nan( 0.0f32 ) / f32 :: NAN ) ) ;
275
+ assert ! ( f32 :: is_nan ( not_nan( 0.0f32 ) % f32 :: NAN ) ) ;
276
276
277
277
let mut number = not_nan ( 5.0f32 ) ;
278
278
number += not_nan ( 4.0f32 ) ;
@@ -285,44 +285,6 @@ fn not_nan32_calculate_correctly() {
285
285
assert_eq ! ( * number, 5.0f32 ) ;
286
286
number %= not_nan ( 4.0f32 ) ;
287
287
assert_eq ! ( * number, 1.0f32 ) ;
288
-
289
- number = not_nan ( 5.0f32 ) ;
290
- number += 4.0f32 ;
291
- assert_eq ! ( * number, 9.0f32 ) ;
292
- number -= 4.0f32 ;
293
- assert_eq ! ( * number, 5.0f32 ) ;
294
- number *= 4.0f32 ;
295
- assert_eq ! ( * number, 20.0f32 ) ;
296
- number /= 4.0f32 ;
297
- assert_eq ! ( * number, 5.0f32 ) ;
298
- number %= 4.0f32 ;
299
- assert_eq ! ( * number, 1.0f32 ) ;
300
-
301
- assert ! ( panic:: catch_unwind( || {
302
- let mut tmp = not_nan( 0.0f32 ) ;
303
- tmp += f32 :: NAN ;
304
- } )
305
- . is_err( ) ) ;
306
- assert ! ( panic:: catch_unwind( || {
307
- let mut tmp = not_nan( 0.0f32 ) ;
308
- tmp -= f32 :: NAN ;
309
- } )
310
- . is_err( ) ) ;
311
- assert ! ( panic:: catch_unwind( || {
312
- let mut tmp = not_nan( 0.0f32 ) ;
313
- tmp *= f32 :: NAN ;
314
- } )
315
- . is_err( ) ) ;
316
- assert ! ( panic:: catch_unwind( || {
317
- let mut tmp = not_nan( 0.0f32 ) ;
318
- tmp /= f32 :: NAN ;
319
- } )
320
- . is_err( ) ) ;
321
- assert ! ( panic:: catch_unwind( || {
322
- let mut tmp = not_nan( 0.0f32 ) ;
323
- tmp %= f32 :: NAN ;
324
- } )
325
- . is_err( ) ) ;
326
288
}
327
289
328
290
#[ test]
@@ -341,22 +303,22 @@ fn not_nan64_fail_when_constructing_with_nan() {
341
303
#[ test]
342
304
fn not_nan64_calculate_correctly ( ) {
343
305
assert_eq ! ( * ( not_nan( 5.0f64 ) + not_nan( 4.0f64 ) ) , 5.0f64 + 4.0f64 ) ;
344
- assert_eq ! ( * ( not_nan( 5.0f64 ) + 4.0f64 ) , 5.0f64 + 4.0f64 ) ;
306
+ assert_eq ! ( not_nan( 5.0f64 ) + 4.0f64 , 5.0f64 + 4.0f64 ) ;
345
307
assert_eq ! ( * ( not_nan( 5.0f64 ) - not_nan( 4.0f64 ) ) , 5.0f64 - 4.0f64 ) ;
346
- assert_eq ! ( * ( not_nan( 5.0f64 ) - 4.0f64 ) , 5.0f64 - 4.0f64 ) ;
308
+ assert_eq ! ( not_nan( 5.0f64 ) - 4.0f64 , 5.0f64 - 4.0f64 ) ;
347
309
assert_eq ! ( * ( not_nan( 5.0f64 ) * not_nan( 4.0f64 ) ) , 5.0f64 * 4.0f64 ) ;
348
- assert_eq ! ( * ( not_nan( 5.0f64 ) * 4.0f64 ) , 5.0f64 * 4.0f64 ) ;
310
+ assert_eq ! ( not_nan( 5.0f64 ) * 4.0f64 , 5.0f64 * 4.0f64 ) ;
349
311
assert_eq ! ( * ( not_nan( 8.0f64 ) / not_nan( 4.0f64 ) ) , 8.0f64 / 4.0f64 ) ;
350
- assert_eq ! ( * ( not_nan( 8.0f64 ) / 4.0f64 ) , 8.0f64 / 4.0f64 ) ;
312
+ assert_eq ! ( not_nan( 8.0f64 ) / 4.0f64 , 8.0f64 / 4.0f64 ) ;
351
313
assert_eq ! ( * ( not_nan( 8.0f64 ) % not_nan( 4.0f64 ) ) , 8.0f64 % 4.0f64 ) ;
352
- assert_eq ! ( * ( not_nan( 8.0f64 ) % 4.0f64 ) , 8.0f64 % 4.0f64 ) ;
314
+ assert_eq ! ( not_nan( 8.0f64 ) % 4.0f64 , 8.0f64 % 4.0f64 ) ;
353
315
assert_eq ! ( * ( -not_nan( 1.0f64 ) ) , -1.0f64 ) ;
354
316
355
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f64 ) + f64 :: NAN ) . is_err ( ) ) ;
356
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f64 ) - f64 :: NAN ) . is_err ( ) ) ;
357
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f64 ) * f64 :: NAN ) . is_err ( ) ) ;
358
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f64 ) / f64 :: NAN ) . is_err ( ) ) ;
359
- assert ! ( panic :: catch_unwind ( || not_nan( 0.0f64 ) % f64 :: NAN ) . is_err ( ) ) ;
317
+ assert ! ( f64 :: is_nan ( not_nan( 0.0f64 ) + f64 :: NAN ) ) ;
318
+ assert ! ( f64 :: is_nan ( not_nan( 0.0f64 ) - f64 :: NAN ) ) ;
319
+ assert ! ( f64 :: is_nan ( not_nan( 0.0f64 ) * f64 :: NAN ) ) ;
320
+ assert ! ( f64 :: is_nan ( not_nan( 0.0f64 ) / f64 :: NAN ) ) ;
321
+ assert ! ( f64 :: is_nan ( not_nan( 0.0f64 ) % f64 :: NAN ) ) ;
360
322
361
323
let mut number = not_nan ( 5.0f64 ) ;
362
324
number += not_nan ( 4.0f64 ) ;
@@ -369,44 +331,6 @@ fn not_nan64_calculate_correctly() {
369
331
assert_eq ! ( * number, 5.0f64 ) ;
370
332
number %= not_nan ( 4.0f64 ) ;
371
333
assert_eq ! ( * number, 1.0f64 ) ;
372
-
373
- number = not_nan ( 5.0f64 ) ;
374
- number += 4.0f64 ;
375
- assert_eq ! ( * number, 9.0f64 ) ;
376
- number -= 4.0f64 ;
377
- assert_eq ! ( * number, 5.0f64 ) ;
378
- number *= 4.0f64 ;
379
- assert_eq ! ( * number, 20.0f64 ) ;
380
- number /= 4.0f64 ;
381
- assert_eq ! ( * number, 5.0f64 ) ;
382
- number %= 4.0f64 ;
383
- assert_eq ! ( * number, 1.0f64 ) ;
384
-
385
- assert ! ( panic:: catch_unwind( || {
386
- let mut tmp = not_nan( 0.0f64 ) ;
387
- tmp += f64 :: NAN ;
388
- } )
389
- . is_err( ) ) ;
390
- assert ! ( panic:: catch_unwind( || {
391
- let mut tmp = not_nan( 0.0f64 ) ;
392
- tmp -= f64 :: NAN ;
393
- } )
394
- . is_err( ) ) ;
395
- assert ! ( panic:: catch_unwind( || {
396
- let mut tmp = not_nan( 0.0f64 ) ;
397
- tmp *= f64 :: NAN ;
398
- } )
399
- . is_err( ) ) ;
400
- assert ! ( panic:: catch_unwind( || {
401
- let mut tmp = not_nan( 0.0f64 ) ;
402
- tmp /= f64 :: NAN ;
403
- } )
404
- . is_err( ) ) ;
405
- assert ! ( panic:: catch_unwind( || {
406
- let mut tmp = not_nan( 0.0f64 ) ;
407
- tmp %= f64 :: NAN ;
408
- } )
409
- . is_err( ) ) ;
410
334
}
411
335
412
336
#[ test]
@@ -578,47 +502,23 @@ fn hash_is_good_for_fractional_numbers() {
578
502
fn test_add_fails_on_nan ( ) {
579
503
let a = not_nan ( f32:: INFINITY ) ;
580
504
let b = not_nan ( f32:: NEG_INFINITY ) ;
581
- let _c = a + b;
505
+ let _c: NotNan < f32 > = a + b;
582
506
}
583
507
584
508
#[ test]
585
509
#[ should_panic]
586
510
fn test_add_fails_on_nan_ref ( ) {
587
511
let a = not_nan ( f32:: INFINITY ) ;
588
512
let b = not_nan ( f32:: NEG_INFINITY ) ;
589
- let _c = a + & b;
513
+ let _c: NotNan < f32 > = a + & b;
590
514
}
591
515
592
516
#[ test]
593
517
#[ should_panic]
594
518
fn test_add_fails_on_nan_ref_ref ( ) {
595
519
let a = not_nan ( f32:: INFINITY ) ;
596
520
let b = not_nan ( f32:: NEG_INFINITY ) ;
597
- let _c = & a + & b;
598
- }
599
-
600
- #[ test]
601
- #[ should_panic]
602
- fn test_add_fails_on_nan_t_ref ( ) {
603
- let a = not_nan ( f32:: INFINITY ) ;
604
- let b = f32:: NEG_INFINITY ;
605
- let _c = a + & b;
606
- }
607
-
608
- #[ test]
609
- #[ should_panic]
610
- fn test_add_fails_on_nan_ref_t_ref ( ) {
611
- let a = not_nan ( f32:: INFINITY ) ;
612
- let b = f32:: NEG_INFINITY ;
613
- let _c = & a + & b;
614
- }
615
-
616
- #[ test]
617
- #[ should_panic]
618
- fn test_add_fails_on_nan_ref_t ( ) {
619
- let a = not_nan ( f32:: INFINITY ) ;
620
- let b = f32:: NEG_INFINITY ;
621
- let _c = & a + b;
521
+ let _c: NotNan < f32 > = & a + & b;
622
522
}
623
523
624
524
#[ test]
@@ -629,22 +529,6 @@ fn test_add_assign_fails_on_nan_ref() {
629
529
a += & b;
630
530
}
631
531
632
- #[ test]
633
- #[ should_panic]
634
- fn test_add_assign_fails_on_nan_t_ref ( ) {
635
- let mut a = not_nan ( f32:: INFINITY ) ;
636
- let b = f32:: NEG_INFINITY ;
637
- a += & b;
638
- }
639
-
640
- #[ test]
641
- #[ should_panic]
642
- fn test_add_assign_fails_on_nan_t ( ) {
643
- let mut a = not_nan ( f32:: INFINITY ) ;
644
- let b = f32:: NEG_INFINITY ;
645
- a += b;
646
- }
647
-
648
532
#[ test]
649
533
fn add ( ) {
650
534
assert_eq ! ( not_nan( 0.0 ) + not_nan( 0.0 ) , 0.0 ) ;
@@ -729,11 +613,11 @@ fn not_nan_panic_safety() {
729
613
num
730
614
} ;
731
615
732
- assert ! ( !catch_op( not_nan( f32 :: INFINITY ) , |a| * a += f32 :: NEG_INFINITY ) . is_nan( ) ) ;
733
- assert ! ( !catch_op( not_nan( f32 :: INFINITY ) , |a| * a -= f32 :: INFINITY ) . is_nan( ) ) ;
734
- assert ! ( !catch_op( not_nan( 0.0 ) , |a| * a *= f32 :: INFINITY ) . is_nan( ) ) ;
735
- assert ! ( !catch_op( not_nan( 0.0 ) , |a| * a /= 0.0 ) . is_nan( ) ) ;
736
- assert ! ( !catch_op( not_nan( 0.0 ) , |a| * a %= 0.0 ) . is_nan( ) ) ;
616
+ assert ! ( !catch_op( not_nan( f32 :: INFINITY ) , |a| * a += not_nan ( f32 :: NEG_INFINITY ) ) . is_nan( ) ) ;
617
+ assert ! ( !catch_op( not_nan( f32 :: INFINITY ) , |a| * a -= not_nan ( f32 :: INFINITY ) ) . is_nan( ) ) ;
618
+ assert ! ( !catch_op( not_nan( 0.0 ) , |a| * a *= not_nan ( f32 :: INFINITY ) ) . is_nan( ) ) ;
619
+ assert ! ( !catch_op( not_nan( 0.0 ) , |a| * a /= not_nan ( 0.0 ) ) . is_nan( ) ) ;
620
+ assert ! ( !catch_op( not_nan( 0.0 ) , |a| * a %= not_nan ( 0.0 ) ) . is_nan( ) ) ;
737
621
}
738
622
739
623
#[ test]
0 commit comments