Josh Stone преди 3 години
родител
ревизия
8bfc6012b5
променени са 2 файла, в които са добавени 11 реда и са изтрити 12 реда
  1. 6 4
      src/ops/wrapping.rs
  2. 5 8
      src/sign.rs

+ 6 - 4
src/ops/wrapping.rs

@@ -285,8 +285,7 @@ fn test_wrapping_traits() {
     assert_eq!(wrapping_add(255, 1), (Wrapping(255u8) + Wrapping(1u8)).0);
     assert_eq!(wrapping_sub(0, 1), (Wrapping(0u8) - Wrapping(1u8)).0);
     assert_eq!(wrapping_mul(255, 2), (Wrapping(255u8) * Wrapping(2u8)).0);
-    // TODO: Test for Wrapping::Neg. Not possible yet since core::ops::Neg was
-    // only added to core::num::Wrapping<_> in Rust 1.10.
+    assert_eq!(wrapping_neg(255), (-Wrapping(255u8)).0);
     assert_eq!(wrapping_shl(255, 8), (Wrapping(255u8) << 8).0);
     assert_eq!(wrapping_shr(255, 8), (Wrapping(255u8) >> 8).0);
 }
@@ -309,8 +308,11 @@ fn wrapping_is_wrappingmul() {
     require_wrappingmul(&Wrapping(42));
 }
 
-// TODO: Test for Wrapping::Neg. Not possible yet since core::ops::Neg was
-// only added to core::num::Wrapping<_> in Rust 1.10.
+#[test]
+fn wrapping_is_wrappingneg() {
+    fn require_wrappingneg<T: WrappingNeg>(_: &T) {}
+    require_wrappingneg(&Wrapping(42));
+}
 
 #[test]
 fn wrapping_is_wrappingshl() {

+ 5 - 8
src/sign.rs

@@ -209,11 +209,8 @@ fn unsigned_wrapping_is_unsigned() {
     require_unsigned(&Wrapping(42_u32));
 }
 
-// Commenting this out since it doesn't compile on Rust 1.8,
-// because on this version Wrapping doesn't implement Neg and therefore can't
-// implement Signed.
-// #[test]
-// fn signed_wrapping_is_signed() {
-//     fn require_signed<T: Signed>(_: &T) {}
-//     require_signed(&Wrapping(-42));
-// }
+#[test]
+fn signed_wrapping_is_signed() {
+    fn require_signed<T: Signed>(_: &T) {}
+    require_signed(&Wrapping(-42));
+}