Skip to content

Commit d3be98e

Browse files
committed
libcore,std,syntax,rustc: move tests into mod tests, make them private (no pub mod or pub fn).
1 parent f10cf26 commit d3be98e

37 files changed

+1211
-1184
lines changed

src/libcore/at_vec.rs

+37-34
Original file line numberDiff line numberDiff line change
@@ -277,45 +277,48 @@ pub mod raw {
277277
pub unsafe fn reserve_at_least<T>(v: &mut @[T], n: uint) {
278278
reserve(v, uint::next_power_of_two(n));
279279
}
280-
281280
}
282281

283-
#[test]
284-
pub fn test() {
285-
// Some code that could use that, then:
286-
fn seq_range(lo: uint, hi: uint) -> @[uint] {
287-
do build |push| {
288-
for uint::range(lo, hi) |i| {
289-
push(i);
282+
#[cfg(test)]
283+
mod test {
284+
use super::*;
285+
286+
#[test]
287+
fn test() {
288+
// Some code that could use that, then:
289+
fn seq_range(lo: uint, hi: uint) -> @[uint] {
290+
do build |push| {
291+
for uint::range(lo, hi) |i| {
292+
push(i);
293+
}
290294
}
291295
}
292-
}
293296

294-
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
295-
assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
296-
assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
297-
}
298-
299-
#[test]
300-
pub fn append_test() {
301-
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
302-
}
297+
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
298+
assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
299+
assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
300+
}
303301

304-
#[test]
305-
pub fn test_from_owned() {
306-
assert!(from_owned::<int>(~[]) == @[]);
307-
assert!(from_owned(~[true]) == @[true]);
308-
assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
309-
assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
310-
assert!(from_owned(~[~[42]]) == @[~[42]]);
311-
}
302+
#[test]
303+
fn append_test() {
304+
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
305+
}
312306

313-
#[test]
314-
pub fn test_from_slice() {
315-
assert!(from_slice::<int>([]) == @[]);
316-
assert!(from_slice([true]) == @[true]);
317-
assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
318-
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
319-
assert!(from_slice([@[42]]) == @[@[42]]);
320-
}
307+
#[test]
308+
fn test_from_owned() {
309+
assert!(from_owned::<int>(~[]) == @[]);
310+
assert!(from_owned(~[true]) == @[true]);
311+
assert!(from_owned(~[1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
312+
assert!(from_owned(~[~"abc", ~"123"]) == @[~"abc", ~"123"]);
313+
assert!(from_owned(~[~[42]]) == @[~[42]]);
314+
}
321315
316+
#[test]
317+
fn test_from_slice() {
318+
assert!(from_slice::<int>([]) == @[]);
319+
assert!(from_slice([true]) == @[true]);
320+
assert!(from_slice([1, 2, 3, 4, 5]) == @[1, 2, 3, 4, 5]);
321+
assert!(from_slice([@"abc", @"123"]) == @[@"abc", @"123"]);
322+
assert!(from_slice([@[42]]) == @[@[42]]);
323+
}
324+
}

src/libcore/cast.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,16 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
111111
****************************************************************************/
112112

113113
#[cfg(test)]
114-
pub mod tests {
114+
mod tests {
115115
use cast::{bump_box_refcount, reinterpret_cast, transmute};
116116

117117
#[test]
118-
pub fn test_reinterpret_cast() {
118+
fn test_reinterpret_cast() {
119119
assert!(1u == unsafe { reinterpret_cast(&1) });
120120
}
121121

122122
#[test]
123-
pub fn test_bump_box_refcount() {
123+
fn test_bump_box_refcount() {
124124
unsafe {
125125
let box = @~"box box box"; // refcount 1
126126
bump_box_refcount(box); // refcount 2
@@ -135,7 +135,7 @@ pub mod tests {
135135
}
136136
137137
#[test]
138-
pub fn test_transmute() {
138+
fn test_transmute() {
139139
use managed::raw::BoxRepr;
140140
unsafe {
141141
let x = @100u8;
@@ -146,7 +146,7 @@ pub mod tests {
146146
}
147147
148148
#[test]
149-
pub fn test_transmute2() {
149+
fn test_transmute2() {
150150
unsafe {
151151
assert!(~[76u8, 0u8] == transmute(~"L"));
152152
}

src/libcore/comm.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,12 @@ pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T)
426426
}
427427
428428
#[cfg(test)]
429-
pub mod test {
429+
mod test {
430430
use either::Right;
431431
use super::{Chan, Port, oneshot, recv_one, stream};
432432
433433
#[test]
434-
pub fn test_select2() {
434+
fn test_select2() {
435435
let (p1, c1) = stream();
436436
let (p2, c2) = stream();
437437
@@ -446,7 +446,7 @@ pub mod test {
446446
}
447447

448448
#[test]
449-
pub fn test_oneshot() {
449+
fn test_oneshot() {
450450
let (c, p) = oneshot::init();
451451

452452
oneshot::client::send(c, ());

0 commit comments

Comments
 (0)