diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-20 01:12:56 +1100 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-12-20 01:26:03 +1100 |
| commit | c00104f36a1dd6aad318d410ffa41b9ec531880a (patch) | |
| tree | 2e317d3960f021384faa3f8ae7f19a9eed1ac849 /src/libstd | |
| parent | b3cee6203457b98c030a8597f97b037a8d447f40 (diff) | |
| download | rust-c00104f36a1dd6aad318d410ffa41b9ec531880a.tar.gz rust-c00104f36a1dd6aad318d410ffa41b9ec531880a.zip | |
std: silence warnings when compiling test.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/c_str.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/native/file.rs | 11 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 4 | ||||
| -rw-r--r-- | src/libstd/local_data.rs | 3 | ||||
| -rw-r--r-- | src/libstd/ptr.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rand/rand_impls.rs | 3 | ||||
| -rw-r--r-- | src/libstd/rt/args.rs | 13 | ||||
| -rw-r--r-- | src/libstd/rt/context.rs | 3 | ||||
| -rw-r--r-- | src/libstd/rt/sched.rs | 2 | ||||
| -rw-r--r-- | src/libstd/rt/task.rs | 2 | ||||
| -rw-r--r-- | src/libstd/run.rs | 2 | ||||
| -rw-r--r-- | src/libstd/str.rs | 1 | ||||
| -rw-r--r-- | src/libstd/task/mod.rs | 8 | ||||
| -rw-r--r-- | src/libstd/vec.rs | 17 |
14 files changed, 28 insertions, 46 deletions
diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 592efe6d981..38deaf2dbcb 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -377,7 +377,6 @@ mod tests { use libc; use ptr; use option::{Some, None}; - use vec; #[test] fn test_str_multistring_parsing() { @@ -440,7 +439,7 @@ mod tests { assert_eq!(*ptr::offset(buf, 0), 'f' as libc::c_char); assert_eq!(*ptr::offset(buf, 1), 'o' as libc::c_char); assert_eq!(*ptr::offset(buf, 2), 'o' as libc::c_char); - assert_eq!(*ptr::offset(buf, 3), 0xff); + assert_eq!(*ptr::offset(buf, 3), 0xff as i8); assert_eq!(*ptr::offset(buf, 4), 0); } }); diff --git a/src/libstd/io/native/file.rs b/src/libstd/io/native/file.rs index 74d18f11a1d..de2655303d6 100644 --- a/src/libstd/io/native/file.rs +++ b/src/libstd/io/native/file.rs @@ -907,22 +907,14 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> { #[cfg(test)] mod tests { use io::native::file::{CFile, FileDesc}; - use io::fs; use io; use libc; use os; - use path::Path; - use rand; use result::Ok; use rt::rtio::RtioFileStream; - fn tmpdir() -> Path { - let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>())); - fs::mkdir(&ret, io::UserRWX); - ret - } - #[ignore(cfg(target_os = "freebsd"))] // hmm, maybe pipes have a tiny buffer + #[test] fn test_file_desc() { // Run this test with some pipes so we don't have to mess around with // opening or closing files. @@ -949,6 +941,7 @@ mod tests { } #[ignore(cfg(windows))] // apparently windows doesn't like tmpfile + #[test] fn test_cfile() { unsafe { let f = libc::tmpfile(); diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 75be56113e9..48030543336 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -220,7 +220,7 @@ mod test { #[test] fn test_null_writer() { let mut s = NullWriter; - let mut buf = ~[0, 0, 0]; + let buf = ~[0, 0, 0]; s.write(buf); s.flush(); } @@ -248,7 +248,7 @@ mod test { struct TestWriter; impl Writer for TestWriter { - fn write(&mut self, buf: &[u8]) { + fn write(&mut self, _buf: &[u8]) { unsafe { writes += 1 } } diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 87fe5ac6f22..ad624f71d0c 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -438,6 +438,9 @@ mod tests { static int_key: Key<@int> = &Key; do task::spawn { set(str_key, @~"string data"); + set(str_key, @~"string data 2"); + set(box_key, @@()); + set(box_key, @@()); set(int_key, @42); // This could cause a segfault if overwriting-destruction is done // with the crazy polymorphic transmute rather than the provided diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 070884c078c..9cf36adc36f 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -557,8 +557,6 @@ pub mod ptr_tests { #[test] fn test_ptr_addition() { - use vec::raw::*; - unsafe { let xs = ~[5, ..16]; let mut ptr = xs.as_ptr(); diff --git a/src/libstd/rand/rand_impls.rs b/src/libstd/rand/rand_impls.rs index ff722b739a8..360f16971ac 100644 --- a/src/libstd/rand/rand_impls.rs +++ b/src/libstd/rand/rand_impls.rs @@ -240,12 +240,14 @@ mod tests { } } + #[test] fn floating_point_edge_cases() { // the test for exact equality is correct here. assert!(ConstantRng(0xffff_ffff).gen::<f32>() != 1.0) assert!(ConstantRng(0xffff_ffff_ffff_ffff).gen::<f64>() != 1.0) } + #[test] fn rand_open() { // this is unlikely to catch an incorrect implementation that // generates exactly 0 or 1, but it keeps it sane. @@ -260,6 +262,7 @@ mod tests { } } + #[test] fn rand_closed() { let mut rng = task_rng(); for _ in range(0, 1_000) { diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 7b27161ab5d..a767af4cc0e 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -64,23 +64,25 @@ pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) } #[cfg(target_os = "freebsd")] mod imp { use cast; - use libc; + #[cfg(not(test))] use libc; use option::{Option, Some, None}; use iter::Iterator; - use str; + #[cfg(not(test))] use str; use unstable::finally::Finally; use unstable::mutex::{Mutex, MUTEX_INIT}; use util; - use vec; + #[cfg(not(test))] use vec; static mut global_args_ptr: uint = 0; static mut lock: Mutex = MUTEX_INIT; + #[cfg(not(test))] pub unsafe fn init(argc: int, argv: **u8) { let args = load_argc_and_argv(argc, argv); put(args); } + #[cfg(not(test))] pub unsafe fn cleanup() { rtassert!(take().is_some()); lock.destroy(); @@ -127,6 +129,7 @@ mod imp { } // Copied from `os`. + #[cfg(not(test))] unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> ~[~str] { vec::from_fn(argc as uint, |i| { str::raw::from_c_str(*(argv as **libc::c_char).offset(i as int)) @@ -163,8 +166,8 @@ mod imp { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "win32")] +#[cfg(target_os = "macos", not(test))] +#[cfg(target_os = "win32", not(test))] mod imp { use option::Option; diff --git a/src/libstd/rt/context.rs b/src/libstd/rt/context.rs index 418557f659b..31cf0696881 100644 --- a/src/libstd/rt/context.rs +++ b/src/libstd/rt/context.rs @@ -395,6 +395,9 @@ pub unsafe fn record_sp_limit(limit: uint) { /// As with the setter, this function does not have a __morestack header and can /// therefore be called in a "we're out of stack" situation. #[inline(always)] +// currently only called by `rust_stack_exhausted`, which doesn't +// exist in a test build. +#[cfg(not(test))] pub unsafe fn get_sp_limit() -> uint { return target_get_sp_limit(); diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs index cd21cdeb711..15aa1602cd0 100644 --- a/src/libstd/rt/sched.rs +++ b/src/libstd/rt/sched.rs @@ -1341,6 +1341,8 @@ mod test { } // FIXME: #9407: xfail-test + #[ignore] + #[test] fn dont_starve_1() { stress_factor().times(|| { do run_in_mt_newsched_task { diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index 62e012f9f41..3299caa089a 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -26,7 +26,6 @@ use local_data; use option::{Option, Some, None}; use rt::borrowck::BorrowRecord; use rt::borrowck; -use rt::context; use rt::context::Context; use rt::env; use rt::kill::Death; @@ -511,6 +510,7 @@ impl Unwinder { // irrelevant for documentation purposes. #[cfg(not(test))] // in testing, use the original libstd's version pub extern "C" fn rust_stack_exhausted() { + use rt::context; use rt::in_green_task_context; use rt::task::Task; use rt::local::Local; diff --git a/src/libstd/run.rs b/src/libstd/run.rs index 85b57fdbc35..d92291bbfbd 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -339,7 +339,7 @@ mod tests { use task::spawn; use unstable::running_on_valgrind; use io::native::file; - use io::{FileNotFound, OtherIoError, Reader, Writer, io_error}; + use io::{FileNotFound, Reader, Writer, io_error}; #[test] #[cfg(not(target_os="android"))] // FIXME(#10380) diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 7225a1ab6cb..5f98a34520c 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -2734,7 +2734,6 @@ mod tests { use option::{None, Some, Option}; use ptr; use str::*; - use vec; use vec::{Vector, ImmutableVector, CopyableVector}; use cmp::{TotalOrd, Less, Equal, Greater}; use send_str::{SendStrOwned, SendStrStatic}; diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 0e56f42f5b9..3310dddc327 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -437,9 +437,6 @@ pub fn failing() -> bool { // !!! These tests are dangerous. If Something is buggy, they will hang, !!! // !!! instead of exiting cleanly. This might wedge the buildbots. !!! -#[cfg(test)] -fn block_forever() { let (po, _ch) = Chan::<()>::new(); po.recv(); } - #[test] fn test_unnamed_task() { use rt::test::run_in_uv_task; @@ -507,11 +504,6 @@ fn test_run_basic() { po.recv(); } -#[cfg(test)] -struct Wrapper { - f: Option<Chan<()>> -} - #[test] fn test_add_wrapper() { let (po, ch) = Chan::new(); diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index ad0d8861ee9..3fa41711d2b 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2678,7 +2678,7 @@ impl<A> Extendable<A> for ~[A] { #[cfg(test)] mod tests { - use option::{None, Option, Some}; + use option::{None, Some}; use mem; use vec::*; use cmp::*; @@ -2688,22 +2688,8 @@ mod tests { fn square_ref(n: &uint) -> uint { square(*n) } - fn is_three(n: &uint) -> bool { *n == 3u } - fn is_odd(n: &uint) -> bool { *n % 2u == 1u } - fn is_equal(x: &uint, y:&uint) -> bool { *x == *y } - - fn square_if_odd_r(n: &uint) -> Option<uint> { - if *n % 2u == 1u { Some(*n * *n) } else { None } - } - - fn square_if_odd_v(n: uint) -> Option<uint> { - if n % 2u == 1u { Some(n * n) } else { None } - } - - fn add(x: uint, y: &uint) -> uint { x + *y } - #[test] fn test_unsafe_ptrs() { unsafe { @@ -2982,6 +2968,7 @@ mod tests { assert_eq!(g, None); } + #[test] fn test_swap_remove() { let mut v = ~[1, 2, 3, 4, 5]; let mut e = v.swap_remove(0); |
