Skip to content

Commit a7f6ec8

Browse files
committed
Use assert_eq! instead of assert! and remove extraneous parentheses
1 parent 939a97f commit a7f6ec8

File tree

4 files changed

+260
-267
lines changed

4 files changed

+260
-267
lines changed

src/libcore/num/float.rs

+96-96
Original file line numberDiff line numberDiff line change
@@ -486,29 +486,29 @@ mod tests {
486486
#[test]
487487
pub fn test_to_str_exact_do_decimal() {
488488
let s = to_str_exact(5.0, 4u);
489-
assert!(s == ~"5.0000");
489+
assert_eq!(s, ~"5.0000");
490490
}
491491
492492
#[test]
493493
pub fn test_from_str() {
494-
assert!(from_str(~"3") == Some(3.));
495-
assert!(from_str(~"3.14") == Some(3.14));
496-
assert!(from_str(~"+3.14") == Some(3.14));
497-
assert!(from_str(~"-3.14") == Some(-3.14));
498-
assert!(from_str(~"2.5E10") == Some(25000000000.));
499-
assert!(from_str(~"2.5e10") == Some(25000000000.));
500-
assert!(from_str(~"25000000000.E-10") == Some(2.5));
501-
assert!(from_str(~".") == Some(0.));
502-
assert!(from_str(~".e1") == Some(0.));
503-
assert!(from_str(~".e-1") == Some(0.));
504-
assert!(from_str(~"5.") == Some(5.));
505-
assert!(from_str(~".5") == Some(0.5));
506-
assert!(from_str(~"0.5") == Some(0.5));
507-
assert!(from_str(~"-.5") == Some(-0.5));
508-
assert!(from_str(~"-5") == Some(-5.));
509-
assert!(from_str(~"inf") == Some(infinity));
510-
assert!(from_str(~"+inf") == Some(infinity));
511-
assert!(from_str(~"-inf") == Some(neg_infinity));
494+
assert_eq!(from_str(~"3"), Some(3.));
495+
assert_eq!(from_str(~"3.14"), Some(3.14));
496+
assert_eq!(from_str(~"+3.14"), Some(3.14));
497+
assert_eq!(from_str(~"-3.14"), Some(-3.14));
498+
assert_eq!(from_str(~"2.5E10"), Some(25000000000.));
499+
assert_eq!(from_str(~"2.5e10"), Some(25000000000.));
500+
assert_eq!(from_str(~"25000000000.E-10"), Some(2.5));
501+
assert_eq!(from_str(~"."), Some(0.));
502+
assert_eq!(from_str(~".e1"), Some(0.));
503+
assert_eq!(from_str(~".e-1"), Some(0.));
504+
assert_eq!(from_str(~"5."), Some(5.));
505+
assert_eq!(from_str(~".5"), Some(0.5));
506+
assert_eq!(from_str(~"0.5"), Some(0.5));
507+
assert_eq!(from_str(~"-.5"), Some(-0.5));
508+
assert_eq!(from_str(~"-5"), Some(-5.));
509+
assert_eq!(from_str(~"inf"), Some(infinity));
510+
assert_eq!(from_str(~"+inf"), Some(infinity));
511+
assert_eq!(from_str(~"-inf"), Some(neg_infinity));
512512
// note: NaN != NaN, hence this slightly complex test
513513
match from_str(~"NaN") {
514514
Some(f) => assert!(is_NaN(f)),
@@ -538,24 +538,24 @@ mod tests {
538538
539539
#[test]
540540
pub fn test_from_str_hex() {
541-
assert!(from_str_hex(~"a4") == Some(164.));
542-
assert!(from_str_hex(~"a4.fe") == Some(164.9921875));
543-
assert!(from_str_hex(~"-a4.fe") == Some(-164.9921875));
544-
assert!(from_str_hex(~"+a4.fe") == Some(164.9921875));
545-
assert!(from_str_hex(~"ff0P4") == Some(0xff00 as float));
546-
assert!(from_str_hex(~"ff0p4") == Some(0xff00 as float));
547-
assert!(from_str_hex(~"ff0p-4") == Some(0xff as float));
548-
assert!(from_str_hex(~".") == Some(0.));
549-
assert!(from_str_hex(~".p1") == Some(0.));
550-
assert!(from_str_hex(~".p-1") == Some(0.));
551-
assert!(from_str_hex(~"f.") == Some(15.));
552-
assert!(from_str_hex(~".f") == Some(0.9375));
553-
assert!(from_str_hex(~"0.f") == Some(0.9375));
554-
assert!(from_str_hex(~"-.f") == Some(-0.9375));
555-
assert!(from_str_hex(~"-f") == Some(-15.));
556-
assert!(from_str_hex(~"inf") == Some(infinity));
557-
assert!(from_str_hex(~"+inf") == Some(infinity));
558-
assert!(from_str_hex(~"-inf") == Some(neg_infinity));
541+
assert_eq!(from_str_hex(~"a4"), Some(164.));
542+
assert_eq!(from_str_hex(~"a4.fe"), Some(164.9921875));
543+
assert_eq!(from_str_hex(~"-a4.fe"), Some(-164.9921875));
544+
assert_eq!(from_str_hex(~"+a4.fe"), Some(164.9921875));
545+
assert_eq!(from_str_hex(~"ff0P4"), Some(0xff00 as float));
546+
assert_eq!(from_str_hex(~"ff0p4"), Some(0xff00 as float));
547+
assert_eq!(from_str_hex(~"ff0p-4"), Some(0xff as float));
548+
assert_eq!(from_str_hex(~"."), Some(0.));
549+
assert_eq!(from_str_hex(~".p1"), Some(0.));
550+
assert_eq!(from_str_hex(~".p-1"), Some(0.));
551+
assert_eq!(from_str_hex(~"f."), Some(15.));
552+
assert_eq!(from_str_hex(~".f"), Some(0.9375));
553+
assert_eq!(from_str_hex(~"0.f"), Some(0.9375));
554+
assert_eq!(from_str_hex(~"-.f"), Some(-0.9375));
555+
assert_eq!(from_str_hex(~"-f"), Some(-15.));
556+
assert_eq!(from_str_hex(~"inf"), Some(infinity));
557+
assert_eq!(from_str_hex(~"+inf"), Some(infinity));
558+
assert_eq!(from_str_hex(~"-inf"), Some(neg_infinity));
559559
// note: NaN != NaN, hence this slightly complex test
560560
match from_str_hex(~"NaN") {
561561
Some(f) => assert!(is_NaN(f)),
@@ -570,11 +570,11 @@ mod tests {
570570
Some(v) if is_zero(v) => assert!(is_positive(v)),
571571
_ => fail!()
572572
}
573-
assert!(from_str_hex(~"e") == Some(14.));
574-
assert!(from_str_hex(~"E") == Some(14.));
575-
assert!(from_str_hex(~"E1") == Some(225.));
576-
assert!(from_str_hex(~"1e1e1") == Some(123361.));
577-
assert!(from_str_hex(~"1e1.1") == Some(481.0625));
573+
assert_eq!(from_str_hex(~"e"), Some(14.));
574+
assert_eq!(from_str_hex(~"E"), Some(14.));
575+
assert_eq!(from_str_hex(~"E1"), Some(225.));
576+
assert_eq!(from_str_hex(~"1e1e1"), Some(123361.));
577+
assert_eq!(from_str_hex(~"1e1.1"), Some(481.0625));
578578
579579
assert!(from_str_hex(~"").is_none());
580580
assert!(from_str_hex(~"x").is_none());
@@ -590,92 +590,92 @@ mod tests {
590590
591591
#[test]
592592
pub fn test_to_str_hex() {
593-
assert!(to_str_hex(164.) == ~"a4");
594-
assert!(to_str_hex(164.9921875) == ~"a4.fe");
595-
assert!(to_str_hex(-164.9921875) == ~"-a4.fe");
596-
assert!(to_str_hex(0xff00 as float) == ~"ff00");
597-
assert!(to_str_hex(-(0xff00 as float)) == ~"-ff00");
598-
assert!(to_str_hex(0.) == ~"0");
599-
assert!(to_str_hex(15.) == ~"f");
600-
assert!(to_str_hex(-15.) == ~"-f");
601-
assert!(to_str_hex(0.9375) == ~"0.f");
602-
assert!(to_str_hex(-0.9375) == ~"-0.f");
603-
assert!(to_str_hex(infinity) == ~"inf");
604-
assert!(to_str_hex(neg_infinity) == ~"-inf");
605-
assert!(to_str_hex(NaN) == ~"NaN");
606-
assert!(to_str_hex(0.) == ~"0");
607-
assert!(to_str_hex(-0.) == ~"-0");
593+
assert_eq!(to_str_hex(164.), ~"a4");
594+
assert_eq!(to_str_hex(164.9921875), ~"a4.fe");
595+
assert_eq!(to_str_hex(-164.9921875), ~"-a4.fe");
596+
assert_eq!(to_str_hex(0xff00 as float), ~"ff00");
597+
assert_eq!(to_str_hex(-(0xff00 as float)), ~"-ff00");
598+
assert_eq!(to_str_hex(0.), ~"0");
599+
assert_eq!(to_str_hex(15.), ~"f");
600+
assert_eq!(to_str_hex(-15.), ~"-f");
601+
assert_eq!(to_str_hex(0.9375), ~"0.f");
602+
assert_eq!(to_str_hex(-0.9375), ~"-0.f");
603+
assert_eq!(to_str_hex(infinity), ~"inf");
604+
assert_eq!(to_str_hex(neg_infinity), ~"-inf");
605+
assert_eq!(to_str_hex(NaN), ~"NaN");
606+
assert_eq!(to_str_hex(0.), ~"0");
607+
assert_eq!(to_str_hex(-0.), ~"-0");
608608
}
609609
610610
#[test]
611611
pub fn test_to_str_radix() {
612-
assert!(to_str_radix(36., 36u) == ~"10");
613-
assert!(to_str_radix(8.125, 2u) == ~"1000.001");
612+
assert_eq!(to_str_radix(36., 36u), ~"10");
613+
assert_eq!(to_str_radix(8.125, 2u), ~"1000.001");
614614
}
615615
616616
#[test]
617617
pub fn test_from_str_radix() {
618-
assert!(from_str_radix(~"10", 36u) == Some(36.));
619-
assert!(from_str_radix(~"1000.001", 2u) == Some(8.125));
618+
assert_eq!(from_str_radix(~"10", 36u), Some(36.));
619+
assert_eq!(from_str_radix(~"1000.001", 2u), Some(8.125));
620620
}
621621
622622
#[test]
623623
pub fn test_positive() {
624-
assert!((is_positive(infinity)));
625-
assert!((is_positive(1.)));
626-
assert!((is_positive(0.)));
627-
assert!((!is_positive(-1.)));
628-
assert!((!is_positive(neg_infinity)));
629-
assert!((!is_positive(1./neg_infinity)));
630-
assert!((!is_positive(NaN)));
624+
assert!(is_positive(infinity));
625+
assert!(is_positive(1.));
626+
assert!(is_positive(0.));
627+
assert!(!is_positive(-1.));
628+
assert!(!is_positive(neg_infinity));
629+
assert!(!is_positive(1./neg_infinity));
630+
assert!(!is_positive(NaN));
631631
}
632632
633633
#[test]
634634
pub fn test_negative() {
635-
assert!((!is_negative(infinity)));
636-
assert!((!is_negative(1.)));
637-
assert!((!is_negative(0.)));
638-
assert!((is_negative(-1.)));
639-
assert!((is_negative(neg_infinity)));
640-
assert!((is_negative(1./neg_infinity)));
641-
assert!((!is_negative(NaN)));
635+
assert!(!is_negative(infinity));
636+
assert!(!is_negative(1.));
637+
assert!(!is_negative(0.));
638+
assert!(is_negative(-1.));
639+
assert!(is_negative(neg_infinity));
640+
assert!(is_negative(1./neg_infinity));
641+
assert!(!is_negative(NaN));
642642
}
643643
644644
#[test]
645645
pub fn test_nonpositive() {
646-
assert!((!is_nonpositive(infinity)));
647-
assert!((!is_nonpositive(1.)));
648-
assert!((!is_nonpositive(0.)));
649-
assert!((is_nonpositive(-1.)));
650-
assert!((is_nonpositive(neg_infinity)));
651-
assert!((is_nonpositive(1./neg_infinity)));
652-
assert!((!is_nonpositive(NaN)));
646+
assert!(!is_nonpositive(infinity));
647+
assert!(!is_nonpositive(1.));
648+
assert!(!is_nonpositive(0.));
649+
assert!(is_nonpositive(-1.));
650+
assert!(is_nonpositive(neg_infinity));
651+
assert!(is_nonpositive(1./neg_infinity));
652+
assert!(!is_nonpositive(NaN));
653653
}
654654
655655
#[test]
656656
pub fn test_nonnegative() {
657-
assert!((is_nonnegative(infinity)));
658-
assert!((is_nonnegative(1.)));
659-
assert!((is_nonnegative(0.)));
660-
assert!((!is_nonnegative(-1.)));
661-
assert!((!is_nonnegative(neg_infinity)));
662-
assert!((!is_nonnegative(1./neg_infinity)));
663-
assert!((!is_nonnegative(NaN)));
657+
assert!(is_nonnegative(infinity));
658+
assert!(is_nonnegative(1.));
659+
assert!(is_nonnegative(0.));
660+
assert!(!is_nonnegative(-1.));
661+
assert!(!is_nonnegative(neg_infinity));
662+
assert!(!is_nonnegative(1./neg_infinity));
663+
assert!(!is_nonnegative(NaN));
664664
}
665665
666666
#[test]
667667
pub fn test_to_str_inf() {
668-
assert!(to_str_digits(infinity, 10u) == ~"inf");
669-
assert!(to_str_digits(-infinity, 10u) == ~"-inf");
668+
assert_eq!(to_str_digits(infinity, 10u), ~"inf");
669+
assert_eq!(to_str_digits(-infinity, 10u), ~"-inf");
670670
}
671671

672672
#[test]
673673
pub fn test_round() {
674-
assert!(round(5.8) == 6.0);
675-
assert!(round(5.2) == 5.0);
676-
assert!(round(3.0) == 3.0);
677-
assert!(round(2.5) == 3.0);
678-
assert!(round(-3.5) == -4.0);
674+
assert_eq!(round(5.8), 6.0);
675+
assert_eq!(round(5.2), 5.0);
676+
assert_eq!(round(3.0), 3.0);
677+
assert_eq!(round(2.5), 3.0);
678+
assert_eq!(round(-3.5), -4.0);
679679
}
680680
}
681681

0 commit comments

Comments
 (0)