about summary refs log tree commit diff
path: root/src/libcore/mem.rs
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2014-06-28 13:57:36 -0700
committerSteven Fackler <sfackler@gmail.com>2014-06-29 15:57:21 -0700
commit1ed646eaf7d09455a086afa11bcd83a7d2a6b0f4 (patch)
tree3c7bc58191bc3b260c4522c115ddf869b986193f /src/libcore/mem.rs
parentff94f867d29a90ab59060c10a62f65994776a8c4 (diff)
downloadrust-1ed646eaf7d09455a086afa11bcd83a7d2a6b0f4.tar.gz
rust-1ed646eaf7d09455a086afa11bcd83a7d2a6b0f4.zip
Extract tests from libcore to a separate crate
Libcore's test infrastructure is complicated by the fact that many lang
items are defined in the crate. The current approach (realcore/realstd
imports) is hacky and hard to work with (tests inside of core::cmp
haven't been run for months!).

Moving tests to a separate crate does mean that they can only test the
public API of libcore, but I don't feel that that is too much of an
issue. The only tests that I had to get rid of were some checking the
various numeric formatters, but those are also exercised through normal
format! calls in other tests.
Diffstat (limited to 'src/libcore/mem.rs')
-rw-r--r--src/libcore/mem.rs179
1 files changed, 0 insertions, 179 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index 39ec830179c..06e28816c1c 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -382,182 +382,3 @@ pub unsafe fn copy_mut_lifetime<'a, S, T>(_ptr: &'a mut S,
                                           ptr: &mut T) -> &'a mut T {
     transmute(ptr)
 }
-
-#[cfg(test)]
-mod tests {
-    use mem::*;
-    use option::{Some,None};
-    use realstd::str::StrAllocating;
-    use realstd::owned::Box;
-    use realstd::vec::Vec;
-    use raw;
-
-    #[test]
-    fn size_of_basic() {
-        assert_eq!(size_of::<u8>(), 1u);
-        assert_eq!(size_of::<u16>(), 2u);
-        assert_eq!(size_of::<u32>(), 4u);
-        assert_eq!(size_of::<u64>(), 8u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86")]
-    #[cfg(target_arch = "arm")]
-    #[cfg(target_arch = "mips")]
-    #[cfg(target_arch = "mipsel")]
-    fn size_of_32() {
-        assert_eq!(size_of::<uint>(), 4u);
-        assert_eq!(size_of::<*const uint>(), 4u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86_64")]
-    fn size_of_64() {
-        assert_eq!(size_of::<uint>(), 8u);
-        assert_eq!(size_of::<*const uint>(), 8u);
-    }
-
-    #[test]
-    fn size_of_val_basic() {
-        assert_eq!(size_of_val(&1u8), 1);
-        assert_eq!(size_of_val(&1u16), 2);
-        assert_eq!(size_of_val(&1u32), 4);
-        assert_eq!(size_of_val(&1u64), 8);
-    }
-
-    #[test]
-    fn align_of_basic() {
-        assert_eq!(align_of::<u8>(), 1u);
-        assert_eq!(align_of::<u16>(), 2u);
-        assert_eq!(align_of::<u32>(), 4u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86")]
-    #[cfg(target_arch = "arm")]
-    #[cfg(target_arch = "mips")]
-    #[cfg(target_arch = "mipsel")]
-    fn align_of_32() {
-        assert_eq!(align_of::<uint>(), 4u);
-        assert_eq!(align_of::<*const uint>(), 4u);
-    }
-
-    #[test]
-    #[cfg(target_arch = "x86_64")]
-    fn align_of_64() {
-        assert_eq!(align_of::<uint>(), 8u);
-        assert_eq!(align_of::<*const uint>(), 8u);
-    }
-
-    #[test]
-    fn align_of_val_basic() {
-        assert_eq!(align_of_val(&1u8), 1u);
-        assert_eq!(align_of_val(&1u16), 2u);
-        assert_eq!(align_of_val(&1u32), 4u);
-    }
-
-    #[test]
-    fn test_swap() {
-        let mut x = 31337i;
-        let mut y = 42i;
-        swap(&mut x, &mut y);
-        assert_eq!(x, 42);
-        assert_eq!(y, 31337);
-    }
-
-    #[test]
-    fn test_replace() {
-        let mut x = Some("test".to_string());
-        let y = replace(&mut x, None);
-        assert!(x.is_none());
-        assert!(y.is_some());
-    }
-
-    #[test]
-    fn test_transmute_copy() {
-        assert_eq!(1u, unsafe { ::mem::transmute_copy(&1i) });
-    }
-
-    #[test]
-    fn test_transmute() {
-        trait Foo {}
-        impl Foo for int {}
-
-        let a = box 100i as Box<Foo>;
-        unsafe {
-            let x: raw::TraitObject = transmute(a);
-            assert!(*(x.data as *const int) == 100);
-            let _x: Box<Foo> = transmute(x);
-        }
-
-        unsafe {
-            assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
-        }
-    }
-}
-
-// FIXME #13642 (these benchmarks should be in another place)
-/// Completely miscellaneous language-construct benchmarks.
-#[cfg(test)]
-mod bench {
-    extern crate test;
-    use self::test::Bencher;
-    use option::{Some,None};
-
-    // Static/dynamic method dispatch
-
-    struct Struct {
-        field: int
-    }
-
-    trait Trait {
-        fn method(&self) -> int;
-    }
-
-    impl Trait for Struct {
-        fn method(&self) -> int {
-            self.field
-        }
-    }
-
-    #[bench]
-    fn trait_vtable_method_call(b: &mut Bencher) {
-        let s = Struct { field: 10 };
-        let t = &s as &Trait;
-        b.iter(|| {
-            t.method()
-        });
-    }
-
-    #[bench]
-    fn trait_static_method_call(b: &mut Bencher) {
-        let s = Struct { field: 10 };
-        b.iter(|| {
-            s.method()
-        });
-    }
-
-    // Overhead of various match forms
-
-    #[bench]
-    fn match_option_some(b: &mut Bencher) {
-        let x = Some(10i);
-        b.iter(|| {
-            match x {
-                Some(y) => y,
-                None => 11
-            }
-        });
-    }
-
-    #[bench]
-    fn match_vec_pattern(b: &mut Bencher) {
-        let x = [1i,2,3,4,5,6];
-        b.iter(|| {
-            match x {
-                [1,2,3,..] => 10i,
-                _ => 11i,
-            }
-        });
-    }
-}