diff options
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/bool.rs | 4 | ||||
| -rw-r--r-- | src/libcore/char.rs | 7 | ||||
| -rw-r--r-- | src/libcore/flate.rs | 2 | ||||
| -rw-r--r-- | src/libcore/logging.rs | 9 | ||||
| -rw-r--r-- | src/libcore/nil.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/f32.rs | 5 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 5 | ||||
| -rw-r--r-- | src/libcore/num/float.rs | 5 | ||||
| -rw-r--r-- | src/libcore/num/int-template.rs | 1 | ||||
| -rw-r--r-- | src/libcore/num/uint-template.rs | 3 | ||||
| -rw-r--r-- | src/libcore/num/uint-template/uint.rs | 87 | ||||
| -rw-r--r-- | src/libcore/option.rs | 3 | ||||
| -rw-r--r-- | src/libcore/owned.rs | 2 | ||||
| -rw-r--r-- | src/libcore/ptr.rs | 21 | ||||
| -rw-r--r-- | src/libcore/repr.rs | 4 | ||||
| -rw-r--r-- | src/libcore/run.rs | 1 | ||||
| -rw-r--r-- | src/libcore/str.rs | 4 | ||||
| -rw-r--r-- | src/libcore/tuple.rs | 3 | ||||
| -rw-r--r-- | src/libcore/unstable.rs | 5 | ||||
| -rw-r--r-- | src/libcore/unstable/at_exit.rs | 2 | ||||
| -rw-r--r-- | src/libcore/unstable/finally.rs | 2 | ||||
| -rw-r--r-- | src/libcore/unstable/global.rs | 6 | ||||
| -rw-r--r-- | src/libcore/util.rs | 1 |
23 files changed, 102 insertions, 81 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 33953e952e8..26a68e3a199 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -11,8 +11,8 @@ //! Boolean logic -use cmp; use option::{None, Option, Some}; +#[cfg(notest)] use cmp; /// Negation / inverse pub pure fn not(v: bool) -> bool { !v } @@ -80,7 +80,7 @@ impl cmp::Eq for bool { #[test] pub fn test_bool_from_str() { do all_values |v| { - assert Some(v) == from_str(bool::to_str(v)) + assert Some(v) == from_str(to_str(v)) } } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index ea12d5fd7ec..36b03af2d38 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -10,13 +10,14 @@ //! Utilities for manipulating the char type -use cmp::Eq; use option::{None, Option, Some}; use str; use u32; use uint; use unicode; +#[cfg(notest)] use cmp::Eq; + /* Lu Uppercase_Letter an uppercase letter Ll Lowercase_Letter a lowercase letter @@ -304,8 +305,8 @@ fn test_to_digit() { #[test] fn test_is_ascii() { - assert str::all(~"banana", char::is_ascii); - assert ! str::all(~"ประเทศไทย中华Việt Nam", char::is_ascii); + assert str::all(~"banana", is_ascii); + assert ! str::all(~"ประเทศไทย中华Việt Nam", is_ascii); } #[test] diff --git a/src/libcore/flate.rs b/src/libcore/flate.rs index f89aa3411f1..4d01c102707 100644 --- a/src/libcore/flate.rs +++ b/src/libcore/flate.rs @@ -19,6 +19,8 @@ use libc::{c_void, size_t, c_int}; use ptr; use vec; +#[cfg(test)] use rand; + extern mod rustrt { unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void, src_buf_len: size_t, diff --git a/src/libcore/logging.rs b/src/libcore/logging.rs index 357a3415ac2..73af0ad3714 100644 --- a/src/libcore/logging.rs +++ b/src/libcore/logging.rs @@ -10,11 +10,7 @@ //! Logging -use cast::transmute; -use io; use libc; -use repr; -use vec; #[nolink] extern mod rustrt { @@ -48,6 +44,11 @@ pub fn console_off() { #[cfg(notest)] #[lang="log_type"] pub fn log_type<T>(level: u32, object: &T) { + use cast::transmute; + use io; + use repr; + use vec; + let bytes = do io::with_bytes_writer |writer| { repr::write_repr(writer, object); }; diff --git a/src/libcore/nil.rs b/src/libcore/nil.rs index 62ed1d24d79..cf2af7e38cc 100644 --- a/src/libcore/nil.rs +++ b/src/libcore/nil.rs @@ -14,6 +14,7 @@ Functions for the unit type. */ +#[cfg(notest)] use cmp::{Eq, Ord}; #[cfg(notest)] diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index d4808bd111f..5100021b954 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -11,17 +11,18 @@ //! Operations and constants for `f32` use cmath; -use cmp; use libc::{c_float, c_int}; use num::NumCast; use num::strconv; use num; -use ops; use option::Option; use unstable::intrinsics::floorf32; use from_str; use to_str; +#[cfg(notest)] use cmp; +#[cfg(notest)] use ops; + pub use cmath::c_float_targ_consts::*; macro_rules! delegate( diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 1c9f8286bcb..9470922b881 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -11,17 +11,18 @@ //! Operations and constants for `f64` use cmath; -use cmp; use libc::{c_double, c_int}; use num::NumCast; use num::strconv; use num; -use ops; use option::Option; use unstable::intrinsics::floorf64; use to_str; use from_str; +#[cfg(notest)] use cmp; +#[cfg(notest)] use ops; + pub use cmath::c_double_targ_consts::*; pub use cmp::{min, max}; diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 366f9e5f7b7..5d912472d7d 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -20,16 +20,17 @@ // PORT this must match in width according to architecture -use cmp::{Eq, Ord}; use f64; use num::NumCast; use num::strconv; use num; -use ops; use option::{None, Option, Some}; use to_str; use from_str; +#[cfg(notest)] use cmp::{Eq, Ord}; +#[cfg(notest)] use ops; + pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt}; pub use f64::logarithm; pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor}; diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 98e3bebd466..c0351e2c619 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -10,7 +10,6 @@ use T = self::inst::T; -use cmp::{Eq, Ord}; use to_str::ToStr; use from_str::FromStr; use num::{ToStrRadix, FromStrRadix}; diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 0811c955078..0dbf7403e27 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -11,7 +11,6 @@ use T = self::inst::T; use T_SIGNED = self::inst::T_SIGNED; -use cmp::{Eq, Ord}; use to_str::ToStr; use from_str::FromStr; use num::{ToStrRadix, FromStrRadix}; @@ -20,6 +19,8 @@ use num; use option::{None, Option, Some}; use prelude::*; +#[cfg(notest)] use cmp::{Eq, Ord}; + pub use cmp::{min, max}; pub const bits : uint = inst::bits; diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 0131bff685d..206f8c0f6ca 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -143,50 +143,51 @@ pub mod inst { #[test] fn test_next_power_of_two() { - assert (uint::next_power_of_two(0u) == 0u); - assert (uint::next_power_of_two(1u) == 1u); - assert (uint::next_power_of_two(2u) == 2u); - assert (uint::next_power_of_two(3u) == 4u); - assert (uint::next_power_of_two(4u) == 4u); - assert (uint::next_power_of_two(5u) == 8u); - assert (uint::next_power_of_two(6u) == 8u); - assert (uint::next_power_of_two(7u) == 8u); - assert (uint::next_power_of_two(8u) == 8u); - assert (uint::next_power_of_two(9u) == 16u); - assert (uint::next_power_of_two(10u) == 16u); - assert (uint::next_power_of_two(11u) == 16u); - assert (uint::next_power_of_two(12u) == 16u); - assert (uint::next_power_of_two(13u) == 16u); - assert (uint::next_power_of_two(14u) == 16u); - assert (uint::next_power_of_two(15u) == 16u); - assert (uint::next_power_of_two(16u) == 16u); - assert (uint::next_power_of_two(17u) == 32u); - assert (uint::next_power_of_two(18u) == 32u); - assert (uint::next_power_of_two(19u) == 32u); - assert (uint::next_power_of_two(20u) == 32u); - assert (uint::next_power_of_two(21u) == 32u); - assert (uint::next_power_of_two(22u) == 32u); - assert (uint::next_power_of_two(23u) == 32u); - assert (uint::next_power_of_two(24u) == 32u); - assert (uint::next_power_of_two(25u) == 32u); - assert (uint::next_power_of_two(26u) == 32u); - assert (uint::next_power_of_two(27u) == 32u); - assert (uint::next_power_of_two(28u) == 32u); - assert (uint::next_power_of_two(29u) == 32u); - assert (uint::next_power_of_two(30u) == 32u); - assert (uint::next_power_of_two(31u) == 32u); - assert (uint::next_power_of_two(32u) == 32u); - assert (uint::next_power_of_two(33u) == 64u); - assert (uint::next_power_of_two(34u) == 64u); - assert (uint::next_power_of_two(35u) == 64u); - assert (uint::next_power_of_two(36u) == 64u); - assert (uint::next_power_of_two(37u) == 64u); - assert (uint::next_power_of_two(38u) == 64u); - assert (uint::next_power_of_two(39u) == 64u); + assert (next_power_of_two(0u) == 0u); + assert (next_power_of_two(1u) == 1u); + assert (next_power_of_two(2u) == 2u); + assert (next_power_of_two(3u) == 4u); + assert (next_power_of_two(4u) == 4u); + assert (next_power_of_two(5u) == 8u); + assert (next_power_of_two(6u) == 8u); + assert (next_power_of_two(7u) == 8u); + assert (next_power_of_two(8u) == 8u); + assert (next_power_of_two(9u) == 16u); + assert (next_power_of_two(10u) == 16u); + assert (next_power_of_two(11u) == 16u); + assert (next_power_of_two(12u) == 16u); + assert (next_power_of_two(13u) == 16u); + assert (next_power_of_two(14u) == 16u); + assert (next_power_of_two(15u) == 16u); + assert (next_power_of_two(16u) == 16u); + assert (next_power_of_two(17u) == 32u); + assert (next_power_of_two(18u) == 32u); + assert (next_power_of_two(19u) == 32u); + assert (next_power_of_two(20u) == 32u); + assert (next_power_of_two(21u) == 32u); + assert (next_power_of_two(22u) == 32u); + assert (next_power_of_two(23u) == 32u); + assert (next_power_of_two(24u) == 32u); + assert (next_power_of_two(25u) == 32u); + assert (next_power_of_two(26u) == 32u); + assert (next_power_of_two(27u) == 32u); + assert (next_power_of_two(28u) == 32u); + assert (next_power_of_two(29u) == 32u); + assert (next_power_of_two(30u) == 32u); + assert (next_power_of_two(31u) == 32u); + assert (next_power_of_two(32u) == 32u); + assert (next_power_of_two(33u) == 64u); + assert (next_power_of_two(34u) == 64u); + assert (next_power_of_two(35u) == 64u); + assert (next_power_of_two(36u) == 64u); + assert (next_power_of_two(37u) == 64u); + assert (next_power_of_two(38u) == 64u); + assert (next_power_of_two(39u) == 64u); } #[test] fn test_overflows() { + use uint; assert (uint::max_value > 0u); assert (uint::min_value <= 0u); assert (uint::min_value + uint::max_value + 1u == 0u); @@ -194,9 +195,9 @@ pub mod inst { #[test] fn test_div() { - assert(uint::div_floor(3u, 4u) == 0u); - assert(uint::div_ceil(3u, 4u) == 1u); - assert(uint::div_round(3u, 4u) == 1u); + assert(div_floor(3u, 4u) == 0u); + assert(div_ceil(3u, 4u) == 1u); + assert(div_round(3u, 4u) == 1u); } #[test] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 55244b81b93..e5719b599bd 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -46,6 +46,9 @@ use kinds::Copy; use util; use num::Zero; +#[cfg(test)] use ptr; +#[cfg(test)] use str; + /// The option type #[deriving_eq] pub enum Option<T> { diff --git a/src/libcore/owned.rs b/src/libcore/owned.rs index 3b839e5a9e0..486ce44147a 100644 --- a/src/libcore/owned.rs +++ b/src/libcore/owned.rs @@ -10,7 +10,7 @@ //! Operations on unique pointer types -use cmp::{Eq, Ord}; +#[cfg(notest)] use cmp::{Eq, Ord}; #[cfg(notest)] impl<T:Eq> Eq for ~T { diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 8996d404dbc..bc2d285ad14 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -11,12 +11,15 @@ //! Unsafe pointer utility functions use cast; -use cmp::{Eq, Ord}; use libc; use libc::{c_void, size_t}; use unstable::intrinsics::{memmove32,memmove64}; use sys; +#[cfg(test)] use vec; +#[cfg(test)] use str; +#[cfg(notest)] use cmp::{Eq, Ord}; + #[nolink] #[abi = "cdecl"] extern mod libc_ { @@ -313,13 +316,13 @@ pub fn test() { let mut v0 = ~[32000u16, 32001u16, 32002u16]; let mut v1 = ~[0u16, 0u16, 0u16]; - ptr::copy_memory(ptr::mut_offset(vec::raw::to_mut_ptr(v1), 1u), - ptr::offset(vec::raw::to_ptr(v0), 1u), 1u); + copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 1u), + offset(vec::raw::to_ptr(v0), 1u), 1u); assert (v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16); - ptr::copy_memory(vec::raw::to_mut_ptr(v1), - ptr::offset(vec::raw::to_ptr(v0), 2u), 1u); + copy_memory(vec::raw::to_mut_ptr(v1), + offset(vec::raw::to_ptr(v0), 2u), 1u); assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16); - ptr::copy_memory(ptr::mut_offset(vec::raw::to_mut_ptr(v1), 2u), + copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u), vec::raw::to_ptr(v0), 1u); assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16); } @@ -358,15 +361,15 @@ pub fn test_buf_len() { #[test] pub fn test_is_null() { - let p: *int = ptr::null(); + let p: *int = null(); assert p.is_null(); assert !p.is_not_null(); - let q = ptr::offset(p, 1u); + let q = offset(p, 1u); assert !q.is_null(); assert q.is_not_null(); - let mp: *mut int = ptr::mut_null(); + let mp: *mut int = mut_null(); assert mp.is_null(); assert !mp.is_not_null(); diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index dd5a427c4ce..d0910e7cefb 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -32,6 +32,8 @@ use vec::UnboxedVecRepr; use vec::raw::{VecRepr, SliceRepr}; use vec; +#[cfg(test)] use io; + pub use managed::raw::BoxRepr; /// Helpers @@ -575,7 +577,7 @@ struct P {a: int, b: float} fn test_repr() { fn exact_test<T>(t: &T, e:&str) { - let s : &str = io::with_str_writer(|w| repr::write_repr(w, t)); + let s : &str = io::with_str_writer(|w| write_repr(w, t)); if s != e { error!("expected '%s', got '%s'", e, s); diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 99a0405cbf8..80d7b4fffdb 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -451,7 +451,6 @@ pub fn waitpid(pid: pid_t) -> int { #[cfg(test)] mod tests { use debug; - use io::WriterUtil; use option::{None, Some}; use os; use run::{readclose, writeclose}; diff --git a/src/libcore/str.rs b/src/libcore/str.rs index dfe58365850..471e1ae5396 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -20,7 +20,7 @@ use at_vec; use cast; use char; -use cmp::{Eq, Ord, TotalOrd, Ordering, Less, Equal, Greater}; +use cmp::{TotalOrd, Ordering, Less, Equal, Greater}; use libc; use option::{None, Option, Some}; use ptr; @@ -29,6 +29,8 @@ use u8; use uint; use vec; +#[cfg(notest)] use cmp::{Eq, Ord}; + /* Section: Creating a string */ diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index dde7d718c13..ae53081c2db 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -10,10 +10,11 @@ //! Operations on tuples -use cmp::{Eq, Ord}; use kinds::Copy; use vec; +#[cfg(notest)] use cmp::{Eq, Ord}; + pub trait CopyableTuple<T, U> { pure fn first() -> T; pure fn second() -> U; diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs index a70a2144c73..dcec424f290 100644 --- a/src/libcore/unstable.rs +++ b/src/libcore/unstable.rs @@ -306,13 +306,8 @@ pub impl<T:Owned> Exclusive<T> { #[cfg(test)] pub mod tests { - use core::option::{None, Some}; - - use cell::Cell; use comm; - use option; use super::exclusive; - use result; use task; use uint; diff --git a/src/libcore/unstable/at_exit.rs b/src/libcore/unstable/at_exit.rs index cb3d6fddc22..63e7613714d 100644 --- a/src/libcore/unstable/at_exit.rs +++ b/src/libcore/unstable/at_exit.rs @@ -15,6 +15,8 @@ use vec; use rand; use libc::{c_void, size_t}; +#[cfg(test)] use uint; + /** Register a function to be run during runtime shutdown. diff --git a/src/libcore/unstable/finally.rs b/src/libcore/unstable/finally.rs index dc6aae6c5cc..9a8b9bdde02 100644 --- a/src/libcore/unstable/finally.rs +++ b/src/libcore/unstable/finally.rs @@ -25,6 +25,8 @@ do || { use ops::Drop; +#[cfg(test)] use task::failing; + pub trait Finally<T> { fn finally(&self, dtor: &fn()) -> T; } diff --git a/src/libcore/unstable/global.rs b/src/libcore/unstable/global.rs index 1187dafdabb..a0c2955673d 100644 --- a/src/libcore/unstable/global.rs +++ b/src/libcore/unstable/global.rs @@ -37,8 +37,10 @@ use unstable::intrinsics::atomic_cxchg; use hashmap::linear::LinearMap; use sys::Closure; -#[cfg(test)] -use private::{SharedMutableState, shared_mutable_state}; +#[cfg(test)] use unstable::{SharedMutableState, shared_mutable_state}; +#[cfg(test)] use unstable::get_shared_immutable_state; +#[cfg(test)] use task::spawn; +#[cfg(test)] use uint; pub type GlobalDataKey<T> = &fn(v: T); diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 48be6178ed2..742eee7dc27 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -103,6 +103,7 @@ pub fn unreachable() -> ! { #[cfg(test)] mod tests { + use option::{None, Some}; use util::{NonCopyable, id, replace, swap}; #[test] |
