Skip to content

Commit cb4ab76

Browse files
committed
Adding missing imports for tests, and gate off others
1 parent bc3bee4 commit cb4ab76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+141
-109
lines changed

src/libcore/bool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
//! Boolean logic
1313
14-
use cmp;
1514
use option::{None, Option, Some};
15+
#[cfg(notest)] use cmp;
1616

1717
/// Negation / inverse
1818
pub pure fn not(v: bool) -> bool { !v }
@@ -80,7 +80,7 @@ impl cmp::Eq for bool {
8080
#[test]
8181
pub fn test_bool_from_str() {
8282
do all_values |v| {
83-
assert Some(v) == from_str(bool::to_str(v))
83+
assert Some(v) == from_str(to_str(v))
8484
}
8585
}
8686

src/libcore/char.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111
//! Utilities for manipulating the char type
1212
13-
use cmp::Eq;
1413
use option::{None, Option, Some};
1514
use str;
1615
use u32;
1716
use uint;
1817
use unicode;
1918

19+
#[cfg(notest)] use cmp::Eq;
20+
2021
/*
2122
Lu Uppercase_Letter an uppercase letter
2223
Ll Lowercase_Letter a lowercase letter
@@ -304,8 +305,8 @@ fn test_to_digit() {
304305

305306
#[test]
306307
fn test_is_ascii() {
307-
assert str::all(~"banana", char::is_ascii);
308-
assert ! str::all(~"ประเทศไทย中华Việt Nam", char::is_ascii);
308+
assert str::all(~"banana", is_ascii);
309+
assert ! str::all(~"ประเทศไทย中华Việt Nam", is_ascii);
309310
}
310311

311312
#[test]

src/libcore/flate.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use libc::{c_void, size_t, c_int};
1919
use ptr;
2020
use vec;
2121

22+
#[cfg(test)] use rand;
23+
2224
extern mod rustrt {
2325
unsafe fn tdefl_compress_mem_to_heap(psrc_buf: *const c_void,
2426
src_buf_len: size_t,

src/libcore/logging.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010

1111
//! Logging
1212
13-
use cast::transmute;
14-
use io;
1513
use libc;
16-
use repr;
17-
use vec;
1814

1915
#[nolink]
2016
extern mod rustrt {
@@ -48,6 +44,11 @@ pub fn console_off() {
4844
#[cfg(notest)]
4945
#[lang="log_type"]
5046
pub fn log_type<T>(level: u32, object: &T) {
47+
use cast::transmute;
48+
use io;
49+
use repr;
50+
use vec;
51+
5152
let bytes = do io::with_bytes_writer |writer| {
5253
repr::write_repr(writer, object);
5354
};

src/libcore/nil.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Functions for the unit type.
1414
1515
*/
1616

17+
#[cfg(notest)]
1718
use cmp::{Eq, Ord};
1819

1920
#[cfg(notest)]

src/libcore/num/f32.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
//! Operations and constants for `f32`
1212
1313
use cmath;
14-
use cmp;
1514
use libc::{c_float, c_int};
1615
use num::NumCast;
1716
use num::strconv;
1817
use num;
19-
use ops;
2018
use option::Option;
2119
use unstable::intrinsics::floorf32;
2220
use from_str;
2321
use to_str;
2422

23+
#[cfg(notest)] use cmp;
24+
#[cfg(notest)] use ops;
25+
2526
pub use cmath::c_float_targ_consts::*;
2627

2728
macro_rules! delegate(

src/libcore/num/f64.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
//! Operations and constants for `f64`
1212
1313
use cmath;
14-
use cmp;
1514
use libc::{c_double, c_int};
1615
use num::NumCast;
1716
use num::strconv;
1817
use num;
19-
use ops;
2018
use option::Option;
2119
use unstable::intrinsics::floorf64;
2220
use to_str;
2321
use from_str;
2422

23+
#[cfg(notest)] use cmp;
24+
#[cfg(notest)] use ops;
25+
2526
pub use cmath::c_double_targ_consts::*;
2627
pub use cmp::{min, max};
2728

src/libcore/num/float.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020

2121
// PORT this must match in width according to architecture
2222

23-
use cmp::{Eq, Ord};
2423
use f64;
2524
use num::NumCast;
2625
use num::strconv;
2726
use num;
28-
use ops;
2927
use option::{None, Option, Some};
3028
use to_str;
3129
use from_str;
3230

31+
#[cfg(notest)] use cmp::{Eq, Ord};
32+
#[cfg(notest)] use ops;
33+
3334
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
3435
pub use f64::logarithm;
3536
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};

src/libcore/num/int-template.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use T = self::inst::T;
1212

13-
use cmp::{Eq, Ord};
1413
use to_str::ToStr;
1514
use from_str::FromStr;
1615
use num::{ToStrRadix, FromStrRadix};

src/libcore/num/uint-template.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use T = self::inst::T;
1212
use T_SIGNED = self::inst::T_SIGNED;
1313

14-
use cmp::{Eq, Ord};
1514
use to_str::ToStr;
1615
use from_str::FromStr;
1716
use num::{ToStrRadix, FromStrRadix};
@@ -20,6 +19,8 @@ use num;
2019
use option::{None, Option, Some};
2120
use prelude::*;
2221

22+
#[cfg(notest)] use cmp::{Eq, Ord};
23+
2324
pub use cmp::{min, max};
2425

2526
pub const bits : uint = inst::bits;

src/libcore/num/uint-template/uint.rs

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -143,60 +143,61 @@ pub mod inst {
143143

144144
#[test]
145145
fn test_next_power_of_two() {
146-
assert (uint::next_power_of_two(0u) == 0u);
147-
assert (uint::next_power_of_two(1u) == 1u);
148-
assert (uint::next_power_of_two(2u) == 2u);
149-
assert (uint::next_power_of_two(3u) == 4u);
150-
assert (uint::next_power_of_two(4u) == 4u);
151-
assert (uint::next_power_of_two(5u) == 8u);
152-
assert (uint::next_power_of_two(6u) == 8u);
153-
assert (uint::next_power_of_two(7u) == 8u);
154-
assert (uint::next_power_of_two(8u) == 8u);
155-
assert (uint::next_power_of_two(9u) == 16u);
156-
assert (uint::next_power_of_two(10u) == 16u);
157-
assert (uint::next_power_of_two(11u) == 16u);
158-
assert (uint::next_power_of_two(12u) == 16u);
159-
assert (uint::next_power_of_two(13u) == 16u);
160-
assert (uint::next_power_of_two(14u) == 16u);
161-
assert (uint::next_power_of_two(15u) == 16u);
162-
assert (uint::next_power_of_two(16u) == 16u);
163-
assert (uint::next_power_of_two(17u) == 32u);
164-
assert (uint::next_power_of_two(18u) == 32u);
165-
assert (uint::next_power_of_two(19u) == 32u);
166-
assert (uint::next_power_of_two(20u) == 32u);
167-
assert (uint::next_power_of_two(21u) == 32u);
168-
assert (uint::next_power_of_two(22u) == 32u);
169-
assert (uint::next_power_of_two(23u) == 32u);
170-
assert (uint::next_power_of_two(24u) == 32u);
171-
assert (uint::next_power_of_two(25u) == 32u);
172-
assert (uint::next_power_of_two(26u) == 32u);
173-
assert (uint::next_power_of_two(27u) == 32u);
174-
assert (uint::next_power_of_two(28u) == 32u);
175-
assert (uint::next_power_of_two(29u) == 32u);
176-
assert (uint::next_power_of_two(30u) == 32u);
177-
assert (uint::next_power_of_two(31u) == 32u);
178-
assert (uint::next_power_of_two(32u) == 32u);
179-
assert (uint::next_power_of_two(33u) == 64u);
180-
assert (uint::next_power_of_two(34u) == 64u);
181-
assert (uint::next_power_of_two(35u) == 64u);
182-
assert (uint::next_power_of_two(36u) == 64u);
183-
assert (uint::next_power_of_two(37u) == 64u);
184-
assert (uint::next_power_of_two(38u) == 64u);
185-
assert (uint::next_power_of_two(39u) == 64u);
146+
assert (next_power_of_two(0u) == 0u);
147+
assert (next_power_of_two(1u) == 1u);
148+
assert (next_power_of_two(2u) == 2u);
149+
assert (next_power_of_two(3u) == 4u);
150+
assert (next_power_of_two(4u) == 4u);
151+
assert (next_power_of_two(5u) == 8u);
152+
assert (next_power_of_two(6u) == 8u);
153+
assert (next_power_of_two(7u) == 8u);
154+
assert (next_power_of_two(8u) == 8u);
155+
assert (next_power_of_two(9u) == 16u);
156+
assert (next_power_of_two(10u) == 16u);
157+
assert (next_power_of_two(11u) == 16u);
158+
assert (next_power_of_two(12u) == 16u);
159+
assert (next_power_of_two(13u) == 16u);
160+
assert (next_power_of_two(14u) == 16u);
161+
assert (next_power_of_two(15u) == 16u);
162+
assert (next_power_of_two(16u) == 16u);
163+
assert (next_power_of_two(17u) == 32u);
164+
assert (next_power_of_two(18u) == 32u);
165+
assert (next_power_of_two(19u) == 32u);
166+
assert (next_power_of_two(20u) == 32u);
167+
assert (next_power_of_two(21u) == 32u);
168+
assert (next_power_of_two(22u) == 32u);
169+
assert (next_power_of_two(23u) == 32u);
170+
assert (next_power_of_two(24u) == 32u);
171+
assert (next_power_of_two(25u) == 32u);
172+
assert (next_power_of_two(26u) == 32u);
173+
assert (next_power_of_two(27u) == 32u);
174+
assert (next_power_of_two(28u) == 32u);
175+
assert (next_power_of_two(29u) == 32u);
176+
assert (next_power_of_two(30u) == 32u);
177+
assert (next_power_of_two(31u) == 32u);
178+
assert (next_power_of_two(32u) == 32u);
179+
assert (next_power_of_two(33u) == 64u);
180+
assert (next_power_of_two(34u) == 64u);
181+
assert (next_power_of_two(35u) == 64u);
182+
assert (next_power_of_two(36u) == 64u);
183+
assert (next_power_of_two(37u) == 64u);
184+
assert (next_power_of_two(38u) == 64u);
185+
assert (next_power_of_two(39u) == 64u);
186186
}
187187

188188
#[test]
189189
fn test_overflows() {
190+
use uint;
190191
assert (uint::max_value > 0u);
191192
assert (uint::min_value <= 0u);
192193
assert (uint::min_value + uint::max_value + 1u == 0u);
193194
}
194195

195196
#[test]
196197
fn test_div() {
197-
assert(uint::div_floor(3u, 4u) == 0u);
198-
assert(uint::div_ceil(3u, 4u) == 1u);
199-
assert(uint::div_round(3u, 4u) == 1u);
198+
assert(div_floor(3u, 4u) == 0u);
199+
assert(div_ceil(3u, 4u) == 1u);
200+
assert(div_round(3u, 4u) == 1u);
200201
}
201202

202203
#[test]

src/libcore/option.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ use kinds::Copy;
4646
use util;
4747
use num::Zero;
4848

49+
#[cfg(test)] use ptr;
50+
#[cfg(test)] use str;
51+
4952
/// The option type
5053
#[deriving_eq]
5154
pub enum Option<T> {

src/libcore/owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Operations on unique pointer types
1212
13-
use cmp::{Eq, Ord};
13+
#[cfg(notest)] use cmp::{Eq, Ord};
1414

1515
#[cfg(notest)]
1616
impl<T:Eq> Eq for ~T {

src/libcore/ptr.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@
1111
//! Unsafe pointer utility functions
1212
1313
use cast;
14-
use cmp::{Eq, Ord};
1514
use libc;
1615
use libc::{c_void, size_t};
1716
use unstable::intrinsics::{memmove32,memmove64};
1817
use sys;
1918

19+
#[cfg(test)] use vec;
20+
#[cfg(test)] use str;
21+
#[cfg(notest)] use cmp::{Eq, Ord};
22+
2023
#[nolink]
2124
#[abi = "cdecl"]
2225
extern mod libc_ {
@@ -313,13 +316,13 @@ pub fn test() {
313316
let mut v0 = ~[32000u16, 32001u16, 32002u16];
314317
let mut v1 = ~[0u16, 0u16, 0u16];
315318

316-
ptr::copy_memory(ptr::mut_offset(vec::raw::to_mut_ptr(v1), 1u),
317-
ptr::offset(vec::raw::to_ptr(v0), 1u), 1u);
319+
copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 1u),
320+
offset(vec::raw::to_ptr(v0), 1u), 1u);
318321
assert (v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16);
319-
ptr::copy_memory(vec::raw::to_mut_ptr(v1),
320-
ptr::offset(vec::raw::to_ptr(v0), 2u), 1u);
322+
copy_memory(vec::raw::to_mut_ptr(v1),
323+
offset(vec::raw::to_ptr(v0), 2u), 1u);
321324
assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16);
322-
ptr::copy_memory(ptr::mut_offset(vec::raw::to_mut_ptr(v1), 2u),
325+
copy_memory(mut_offset(vec::raw::to_mut_ptr(v1), 2u),
323326
vec::raw::to_ptr(v0), 1u);
324327
assert (v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16);
325328
}
@@ -358,15 +361,15 @@ pub fn test_buf_len() {
358361

359362
#[test]
360363
pub fn test_is_null() {
361-
let p: *int = ptr::null();
364+
let p: *int = null();
362365
assert p.is_null();
363366
assert !p.is_not_null();
364367

365-
let q = ptr::offset(p, 1u);
368+
let q = offset(p, 1u);
366369
assert !q.is_null();
367370
assert q.is_not_null();
368371

369-
let mp: *mut int = ptr::mut_null();
372+
let mp: *mut int = mut_null();
370373
assert mp.is_null();
371374
assert !mp.is_not_null();
372375

src/libcore/repr.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ use vec::UnboxedVecRepr;
3232
use vec::raw::{VecRepr, SliceRepr};
3333
use vec;
3434

35+
#[cfg(test)] use io;
36+
3537
pub use managed::raw::BoxRepr;
3638

3739
/// Helpers
@@ -575,7 +577,7 @@ struct P {a: int, b: float}
575577
fn test_repr() {
576578

577579
fn exact_test<T>(t: &T, e:&str) {
578-
let s : &str = io::with_str_writer(|w| repr::write_repr(w, t));
580+
let s : &str = io::with_str_writer(|w| write_repr(w, t));
579581
if s != e {
580582
error!("expected '%s', got '%s'",
581583
e, s);

src/libcore/run.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ pub fn waitpid(pid: pid_t) -> int {
451451
#[cfg(test)]
452452
mod tests {
453453
use debug;
454-
use io::WriterUtil;
455454
use option::{None, Some};
456455
use os;
457456
use run::{readclose, writeclose};

src/libcore/str.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use at_vec;
2121
use cast;
2222
use char;
23-
use cmp::{Eq, Ord, TotalOrd, Ordering, Less, Equal, Greater};
23+
use cmp::{TotalOrd, Ordering, Less, Equal, Greater};
2424
use libc;
2525
use option::{None, Option, Some};
2626
use ptr;
@@ -29,6 +29,8 @@ use u8;
2929
use uint;
3030
use vec;
3131

32+
#[cfg(notest)] use cmp::{Eq, Ord};
33+
3234
/*
3335
Section: Creating a string
3436
*/

0 commit comments

Comments
 (0)