@@ -398,7 +398,6 @@ mod tests {
398
398
extern crate core;
399
399
400
400
use self :: core:: f64:: consts:: { E , PI } ;
401
- use self :: core:: f64:: { EPSILON , INFINITY , MAX , MIN , MIN_POSITIVE , NAN , NEG_INFINITY } ;
402
401
use super :: pow;
403
402
404
403
const POS_ZERO : & [ f64 ] = & [ 0.0 ] ;
@@ -407,15 +406,15 @@ mod tests {
407
406
const NEG_ONE : & [ f64 ] = & [ -1.0 ] ;
408
407
const POS_FLOATS : & [ f64 ] = & [ 99.0 / 70.0 , E , PI ] ;
409
408
const NEG_FLOATS : & [ f64 ] = & [ -99.0 / 70.0 , -E , -PI ] ;
410
- const POS_SMALL_FLOATS : & [ f64 ] = & [ ( 1.0 / 2.0 ) , MIN_POSITIVE , EPSILON ] ;
411
- const NEG_SMALL_FLOATS : & [ f64 ] = & [ -( 1.0 / 2.0 ) , -MIN_POSITIVE , -EPSILON ] ;
412
- const POS_EVENS : & [ f64 ] = & [ 2.0 , 6.0 , 8.0 , 10.0 , 22.0 , 100.0 , MAX ] ;
413
- const NEG_EVENS : & [ f64 ] = & [ MIN , -100.0 , -22.0 , -10.0 , -8.0 , -6.0 , -2.0 ] ;
409
+ const POS_SMALL_FLOATS : & [ f64 ] = & [ ( 1.0 / 2.0 ) , f64 :: MIN_POSITIVE , f64 :: EPSILON ] ;
410
+ const NEG_SMALL_FLOATS : & [ f64 ] = & [ -( 1.0 / 2.0 ) , -f64 :: MIN_POSITIVE , -f64 :: EPSILON ] ;
411
+ const POS_EVENS : & [ f64 ] = & [ 2.0 , 6.0 , 8.0 , 10.0 , 22.0 , 100.0 , f64 :: MAX ] ;
412
+ const NEG_EVENS : & [ f64 ] = & [ f64 :: MIN , -100.0 , -22.0 , -10.0 , -8.0 , -6.0 , -2.0 ] ;
414
413
const POS_ODDS : & [ f64 ] = & [ 3.0 , 7.0 ] ;
415
414
const NEG_ODDS : & [ f64 ] = & [ -7.0 , -3.0 ] ;
416
- const NANS : & [ f64 ] = & [ NAN ] ;
417
- const POS_INF : & [ f64 ] = & [ INFINITY ] ;
418
- const NEG_INF : & [ f64 ] = & [ NEG_INFINITY ] ;
415
+ const NANS : & [ f64 ] = & [ f64 :: NAN ] ;
416
+ const POS_INF : & [ f64 ] = & [ f64 :: INFINITY ] ;
417
+ const NEG_INF : & [ f64 ] = & [ f64 :: NEG_INFINITY ] ;
419
418
420
419
const ALL : & [ & [ f64 ] ] = & [
421
420
POS_ZERO ,
@@ -492,83 +491,83 @@ mod tests {
492
491
#[ test]
493
492
fn nan_inputs ( ) {
494
493
// NAN as the base:
495
- // (NAN ^ anything *but 0* should be NAN)
496
- test_sets_as_exponent ( NAN , & ALL [ 2 ..] , NAN ) ;
494
+ // (f64:: NAN ^ anything *but 0* should be f64:: NAN)
495
+ test_sets_as_exponent ( f64 :: NAN , & ALL [ 2 ..] , f64 :: NAN ) ;
497
496
498
- // NAN as the exponent:
499
- // (anything *but 1* ^ NAN should be NAN)
500
- test_sets_as_base ( & ALL [ ..( ALL . len ( ) - 2 ) ] , NAN , NAN ) ;
497
+ // f64:: NAN as the exponent:
498
+ // (anything *but 1* ^ f64:: NAN should be f64:: NAN)
499
+ test_sets_as_base ( & ALL [ ..( ALL . len ( ) - 2 ) ] , f64 :: NAN , f64 :: NAN ) ;
501
500
}
502
501
503
502
#[ test]
504
503
fn infinity_as_base ( ) {
505
504
// Positive Infinity as the base:
506
- // (+Infinity ^ positive anything but 0 and NAN should be +Infinity)
507
- test_sets_as_exponent ( INFINITY , & POS [ 1 ..] , INFINITY ) ;
505
+ // (+Infinity ^ positive anything but 0 and f64:: NAN should be +Infinity)
506
+ test_sets_as_exponent ( f64 :: INFINITY , & POS [ 1 ..] , f64 :: INFINITY ) ;
508
507
509
- // (+Infinity ^ negative anything except 0 and NAN should be 0.0)
510
- test_sets_as_exponent ( INFINITY , & NEG [ 1 ..] , 0.0 ) ;
508
+ // (+Infinity ^ negative anything except 0 and f64:: NAN should be 0.0)
509
+ test_sets_as_exponent ( f64 :: INFINITY , & NEG [ 1 ..] , 0.0 ) ;
511
510
512
511
// Negative Infinity as the base:
513
512
// (-Infinity ^ positive odd ints should be -Infinity)
514
- test_sets_as_exponent ( NEG_INFINITY , & [ POS_ODDS ] , NEG_INFINITY ) ;
513
+ test_sets_as_exponent ( f64 :: NEG_INFINITY , & [ POS_ODDS ] , f64 :: NEG_INFINITY ) ;
515
514
516
515
// (-Infinity ^ anything but odd ints should be == -0 ^ (-anything))
517
516
// We can lump in pos/neg odd ints here because they don't seem to
518
517
// cause panics (div by zero) in release mode (I think).
519
- test_sets ( ALL , & |v : f64 | pow ( NEG_INFINITY , v) , & |v : f64 | pow ( -0.0 , -v) ) ;
518
+ test_sets ( ALL , & |v : f64 | pow ( f64 :: NEG_INFINITY , v) , & |v : f64 | pow ( -0.0 , -v) ) ;
520
519
}
521
520
522
521
#[ test]
523
522
fn infinity_as_exponent ( ) {
524
523
// Positive/Negative base greater than 1:
525
- // (pos/neg > 1 ^ Infinity should be Infinity - note this excludes NAN as the base)
526
- test_sets_as_base ( & ALL [ 5 ..( ALL . len ( ) - 2 ) ] , INFINITY , INFINITY ) ;
524
+ // (pos/neg > 1 ^ Infinity should be Infinity - note this excludes f64:: NAN as the base)
525
+ test_sets_as_base ( & ALL [ 5 ..( ALL . len ( ) - 2 ) ] , f64 :: INFINITY , f64 :: INFINITY ) ;
527
526
528
527
// (pos/neg > 1 ^ -Infinity should be 0.0)
529
- test_sets_as_base ( & ALL [ 5 ..ALL . len ( ) - 2 ] , NEG_INFINITY , 0.0 ) ;
528
+ test_sets_as_base ( & ALL [ 5 ..ALL . len ( ) - 2 ] , f64 :: NEG_INFINITY , 0.0 ) ;
530
529
531
530
// Positive/Negative base less than 1:
532
531
let base_below_one = & [ POS_ZERO , NEG_ZERO , NEG_SMALL_FLOATS , POS_SMALL_FLOATS ] ;
533
532
534
- // (pos/neg < 1 ^ Infinity should be 0.0 - this also excludes NAN as the base)
535
- test_sets_as_base ( base_below_one, INFINITY , 0.0 ) ;
533
+ // (pos/neg < 1 ^ Infinity should be 0.0 - this also excludes f64:: NAN as the base)
534
+ test_sets_as_base ( base_below_one, f64 :: INFINITY , 0.0 ) ;
536
535
537
536
// (pos/neg < 1 ^ -Infinity should be Infinity)
538
- test_sets_as_base ( base_below_one, NEG_INFINITY , INFINITY ) ;
537
+ test_sets_as_base ( base_below_one, f64 :: NEG_INFINITY , f64 :: INFINITY ) ;
539
538
540
539
// Positive/Negative 1 as the base:
541
540
// (pos/neg 1 ^ Infinity should be 1)
542
- test_sets_as_base ( & [ NEG_ONE , POS_ONE ] , INFINITY , 1.0 ) ;
541
+ test_sets_as_base ( & [ NEG_ONE , POS_ONE ] , f64 :: INFINITY , 1.0 ) ;
543
542
544
543
// (pos/neg 1 ^ -Infinity should be 1)
545
- test_sets_as_base ( & [ NEG_ONE , POS_ONE ] , NEG_INFINITY , 1.0 ) ;
544
+ test_sets_as_base ( & [ NEG_ONE , POS_ONE ] , f64 :: NEG_INFINITY , 1.0 ) ;
546
545
}
547
546
548
547
#[ test]
549
548
fn zero_as_base ( ) {
550
549
// Positive Zero as the base:
551
- // (+0 ^ anything positive but 0 and NAN should be +0)
550
+ // (+0 ^ anything positive but 0 and f64:: NAN should be +0)
552
551
test_sets_as_exponent ( 0.0 , & POS [ 1 ..] , 0.0 ) ;
553
552
554
- // (+0 ^ anything negative but 0 and NAN should be Infinity)
553
+ // (+0 ^ anything negative but 0 and f64:: NAN should be Infinity)
555
554
// (this should panic because we're dividing by zero)
556
- test_sets_as_exponent ( 0.0 , & NEG [ 1 ..] , INFINITY ) ;
555
+ test_sets_as_exponent ( 0.0 , & NEG [ 1 ..] , f64 :: INFINITY ) ;
557
556
558
557
// Negative Zero as the base:
559
- // (-0 ^ anything positive but 0, NAN, and odd ints should be +0)
558
+ // (-0 ^ anything positive but 0, f64:: NAN, and odd ints should be +0)
560
559
test_sets_as_exponent ( -0.0 , & POS [ 3 ..] , 0.0 ) ;
561
560
562
- // (-0 ^ anything negative but 0, NAN, and odd ints should be Infinity)
561
+ // (-0 ^ anything negative but 0, f64:: NAN, and odd ints should be Infinity)
563
562
// (should panic because of divide by zero)
564
- test_sets_as_exponent ( -0.0 , & NEG [ 3 ..] , INFINITY ) ;
563
+ test_sets_as_exponent ( -0.0 , & NEG [ 3 ..] , f64 :: INFINITY ) ;
565
564
566
565
// (-0 ^ positive odd ints should be -0)
567
566
test_sets_as_exponent ( -0.0 , & [ POS_ODDS ] , -0.0 ) ;
568
567
569
568
// (-0 ^ negative odd ints should be -Infinity)
570
569
// (should panic because of divide by zero)
571
- test_sets_as_exponent ( -0.0 , & [ NEG_ODDS ] , NEG_INFINITY ) ;
570
+ test_sets_as_exponent ( -0.0 , & [ NEG_ODDS ] , f64 :: NEG_INFINITY ) ;
572
571
}
573
572
574
573
#[ test]
@@ -583,21 +582,17 @@ mod tests {
583
582
584
583
// Factoring -1 out:
585
584
// (negative anything ^ integer should be (-1 ^ integer) * (positive anything ^ integer))
586
- ( & [ POS_ZERO , NEG_ZERO , POS_ONE , NEG_ONE , POS_EVENS , NEG_EVENS ] ) . iter ( ) . for_each (
587
- |int_set| {
588
- int_set. iter ( ) . for_each ( |int| {
589
- test_sets ( ALL , & |v : f64 | pow ( -v, * int) , & |v : f64 | {
590
- pow ( -1.0 , * int) * pow ( v, * int)
591
- } ) ;
592
- } )
593
- } ,
594
- ) ;
585
+ [ POS_ZERO , NEG_ZERO , POS_ONE , NEG_ONE , POS_EVENS , NEG_EVENS ] . iter ( ) . for_each ( |int_set| {
586
+ int_set. iter ( ) . for_each ( |int| {
587
+ test_sets ( ALL , & |v : f64 | pow ( -v, * int) , & |v : f64 | pow ( -1.0 , * int) * pow ( v, * int) ) ;
588
+ } )
589
+ } ) ;
595
590
596
591
// Negative base (imaginary results):
597
592
// (-anything except 0 and Infinity ^ non-integer should be NAN)
598
- ( & NEG [ 1 ..( NEG . len ( ) - 1 ) ] ) . iter ( ) . for_each ( |set| {
593
+ NEG [ 1 ..( NEG . len ( ) - 1 ) ] . iter ( ) . for_each ( |set| {
599
594
set. iter ( ) . for_each ( |val| {
600
- test_sets ( & ALL [ 3 ..7 ] , & |v : f64 | pow ( * val, v) , & |_| NAN ) ;
595
+ test_sets ( & ALL [ 3 ..7 ] , & |v : f64 | pow ( * val, v) , & |_| f64 :: NAN ) ;
601
596
} )
602
597
} ) ;
603
598
}
0 commit comments