diff options
| author | NODA, Kai <nodakai@gmail.com> | 2014-10-05 18:11:17 +0800 |
|---|---|---|
| committer | NODA, Kai <nodakai@gmail.com> | 2014-10-13 14:16:22 +0800 |
| commit | f27ad3d3e99ce679f782607971a9f6f18befa503 (patch) | |
| tree | 388f850cfb1e4d06077dfa6cd28a0e79eda28c07 /src/libstd/bitflags.rs | |
| parent | a6e0c76ef4b8ed87698dc9fe51e952039d33b913 (diff) | |
Clean up rustc warnings.
compiletest: compact "linux" "macos" etc.as "unix".
liballoc: remove a superfluous "use".
libcollections: remove invocations of deprecated methods in favor of
their suggested replacements and use "_" for a loop counter.
libcoretest: remove invocations of deprecated methods; also add
"allow(deprecated)" for testing a deprecated method itself.
libglob: use "cfg_attr".
libgraphviz: add a test for one of data constructors.
libgreen: remove a superfluous "use".
libnum: "allow(type_overflow)" for type cast into u8 in a test code.
librustc: names of static variables should be in upper case.
libserialize: v[i] instead of get().
libstd/ascii: to_lowercase() instead of to_lower().
libstd/bitflags: modify AnotherSetOfFlags to use i8 as its backend.
It will serve better for testing various aspects of bitflags!.
libstd/collections: "allow(deprecated)" for testing a deprecated
method itself.
libstd/io: remove invocations of deprecated methods and superfluous "use".
Also add #[test] where it was missing.
libstd/num: introduce a helper function to effectively remove
invocations of a deprecated method.
libstd/path and rand: remove invocations of deprecated methods and
superfluous "use".
libstd/task and libsync/comm: "allow(deprecated)" for testing
a deprecated method itself.
libsync/deque: remove superfluous "unsafe".
libsync/mutex and once: names of static variables should be in upper case.
libterm: introduce a helper function to effectively remove
invocations of a deprecated method.
We still see a few warnings about using obsoleted native::task::spawn()
in the test modules for libsync. I'm not sure how I should replace them
with std::task::TaksBuilder and native::task::NativeTaskBuilder
(dependency to libstd?)
Signed-off-by: NODA, Kai <nodakai@gmail.com>
Diffstat (limited to 'src/libstd/bitflags.rs')
| -rw-r--r-- | src/libstd/bitflags.rs | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/libstd/bitflags.rs b/src/libstd/bitflags.rs index adb55f2cc8c..42e3a823ff4 100644 --- a/src/libstd/bitflags.rs +++ b/src/libstd/bitflags.rs @@ -273,8 +273,8 @@ mod tests { } bitflags! { - flags AnotherSetOfFlags: uint { - const AnotherFlag = 1u, + flags AnotherSetOfFlags: i8 { + const AnotherFlag = -1_i8, } } @@ -283,6 +283,9 @@ mod tests { assert_eq!(Flags::empty().bits(), 0x00000000); assert_eq!(FlagA.bits(), 0x00000001); assert_eq!(FlagABC.bits(), 0x00000111); + + assert_eq!(AnotherSetOfFlags::empty().bits(), 0x00); + assert_eq!(AnotherFlag.bits(), !0_i8); } #[test] @@ -292,6 +295,8 @@ mod tests { assert!(Flags::from_bits(0x10) == Some(FlagB)); assert!(Flags::from_bits(0x11) == Some(FlagA | FlagB)); assert!(Flags::from_bits(0x1000) == None); + + assert!(AnotherSetOfFlags::from_bits(!0_i8) == Some(AnotherFlag)); } #[test] @@ -302,6 +307,8 @@ mod tests { assert!(Flags::from_bits_truncate(0x11) == (FlagA | FlagB)); assert!(Flags::from_bits_truncate(0x1000) == Flags::empty()); assert!(Flags::from_bits_truncate(0x1001) == FlagA); + + assert!(AnotherSetOfFlags::from_bits_truncate(0_i8) == AnotherSetOfFlags::empty()); } #[test] @@ -309,6 +316,8 @@ mod tests { assert!(Flags::empty().is_empty()); assert!(!FlagA.is_empty()); assert!(!FlagABC.is_empty()); + + assert!(!AnotherFlag.is_empty()); } #[test] @@ -316,6 +325,8 @@ mod tests { assert!(Flags::all().is_all()); assert!(!FlagA.is_all()); assert!(FlagABC.is_all()); + + assert!(AnotherFlag.is_all()); } #[test] @@ -323,6 +334,8 @@ mod tests { let e1 = Flags::empty(); let e2 = Flags::empty(); assert!(!e1.intersects(e2)); + + assert!(AnotherFlag.intersects(AnotherFlag)); } #[test] @@ -353,6 +366,8 @@ mod tests { assert!(!e1.contains(e2)); assert!(e2.contains(e1)); assert!(FlagABC.contains(e2)); + + assert!(AnotherFlag.contains(AnotherFlag)); } #[test] @@ -361,6 +376,10 @@ mod tests { let e2 = FlagA | FlagB; e1.insert(e2); assert!(e1 == e2); + + let mut e3 = AnotherSetOfFlags::empty(); + e3.insert(AnotherFlag); + assert!(e3 == AnotherFlag); } #[test] @@ -369,6 +388,10 @@ mod tests { let e2 = FlagA | FlagC; e1.remove(e2); assert!(e1 == FlagB); + + let mut e3 = AnotherFlag; + e3.remove(AnotherFlag); + assert!(e3 == AnotherSetOfFlags::empty()); } #[test] @@ -383,6 +406,10 @@ mod tests { let mut e3 = e1; e3.toggle(e2); assert!(e3 == FlagA | FlagB); + + let mut m4 = AnotherSetOfFlags::empty(); + m4.toggle(AnotherSetOfFlags::empty()); + assert!(m4 == AnotherSetOfFlags::empty()); } #[test] |
