Skip to content

Commit 16e8af9

Browse files
committed
auto merge of #5895 : huonw/rust/no-pub-tests, r=thestinger
This patch is a sledge hammer that moves all tests into `#[cfg(test)] mod test { .. }`, and makes them private, there were several instances of `pub mod tests { #[test] pub fn ... } `. (The reason for this is I was playing with using `syntax` to index code ([result so far](http://www.ug.it.usyd.edu.au/~hwil7821/rust-api/)) and it was getting some junk from the tests.) The rustdoc commit is particularly brutal, so it's fine if that one isn't landed.
2 parents 447caf9 + 40e3577 commit 16e8af9

Some content is hidden

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

52 files changed

+2836
-2803
lines changed

src/libcore/at_vec.rs

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -277,45 +277,49 @@ 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+
use prelude::*;
286+
287+
#[test]
288+
fn test() {
289+
// Some code that could use that, then:
290+
fn seq_range(lo: uint, hi: uint) -> @[uint] {
291+
do build |push| {
292+
for uint::range(lo, hi) |i| {
293+
push(i);
294+
}
290295
}
291296
}
292-
}
293297

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-
}
298+
assert_eq!(seq_range(10, 15), @[10, 11, 12, 13, 14]);
299+
assert!(from_fn(5, |x| x+1) == @[1, 2, 3, 4, 5]);
300+
assert!(from_elem(5, 3.14) == @[3.14, 3.14, 3.14, 3.14, 3.14]);
301+
}
303302

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-
}
303+
#[test]
304+
fn append_test() {
305+
assert!(@[1,2,3] + @[4,5,6] == @[1,2,3,4,5,6]);
306+
}
312307

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

src/libcore/cast.rs

Lines changed: 5 additions & 5 deletions
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

Lines changed: 3 additions & 3 deletions
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)