Skip to content

Rename tests modules to test to reflect guidelines. #23870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/doc/trpl/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub fn add_two(a: i32) -> i32 {
}

#[cfg(test)]
mod tests {
mod test {
use super::add_two;

#[test]
Expand All @@ -241,7 +241,7 @@ mod tests {
}
```

There's a few changes here. The first is the introduction of a `mod tests` with
There's a few changes here. The first is the introduction of a `mod test` with
a `cfg` attribute. The module allows us to group all of our tests together, and
to also define helper functions if needed, that don't become a part of the rest
of our crate. The `cfg` attribute only compiles our test code if we're
Expand All @@ -260,7 +260,7 @@ pub fn add_two(a: i32) -> i32 {
}

#[cfg(test)]
mod tests {
mod test {
use super::*;

#[test]
Expand Down Expand Up @@ -382,7 +382,7 @@ pub fn add_two(a: i32) -> i32 {
}

#[cfg(test)]
mod tests {
mod test {
use super::*;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl<T: Hash> Hash for Arc<T> {
}

#[cfg(test)]
mod tests {
mod test {
use std::clone::Clone;
use std::sync::mpsc::channel;
use std::mem::drop;
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ impl<T> RcBoxPtr<T> for Weak<T> {
}

#[cfg(test)]
mod tests {
mod test {
use super::{Rc, Weak, weak_count, strong_count};
use std::boxed::Box;
use std::cell::RefCell;
Expand Down
2 changes: 1 addition & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ impl<T> Drop for TypedArena<T> {
}

#[cfg(test)]
mod tests {
mod test {
extern crate test;
use self::test::Bencher;
use super::{Arena, TypedArena};
Expand Down
2 changes: 1 addition & 1 deletion src/libcoretest/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

macro_rules! int_module { ($T:ty, $T_i:ident) => (
#[cfg(test)]
mod tests {
mod test {
use core::$T_i::*;
use core::isize;
use core::num::{FromStrRadix, Int, SignedInt};
Expand Down
2 changes: 1 addition & 1 deletion src/libcoretest/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

macro_rules! uint_module { ($T:ty, $T_i:ident) => (
#[cfg(test)]
mod tests {
mod test {
use core::$T_i::*;
use core::num::Int;
use num;
Expand Down
2 changes: 1 addition & 1 deletion src/libflate/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn inflate_bytes_zlib(bytes: &[u8]) -> Result<Bytes,Error> {
}

#[cfg(test)]
mod tests {
mod test {
#![allow(deprecated)]
use super::{inflate_bytes, deflate_bytes};
use std::rand;
Expand Down
2 changes: 1 addition & 1 deletion src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ impl<'a> Parser<'a> {
}

#[cfg(test)]
mod tests {
mod test {
use super::*;

fn same(fmt: &'static str, p: &[Piece<'static>]) {
Expand Down
2 changes: 1 addition & 1 deletion src/libgetopts/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ fn test_split_within() {
}

#[cfg(test)]
mod tests {
mod test {
use super::*;
use super::Fail::*;

Expand Down
2 changes: 1 addition & 1 deletion src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
}

#[cfg(test)]
mod tests {
mod test {
use self::NodeLabels::*;
use super::{Id, Labeller, Nodes, Edges, GraphWalk, render};
use super::LabelText::{self, LabelStr, EscStr};
Expand Down
2 changes: 1 addition & 1 deletion src/liblog/directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<String>) {
}

#[cfg(test)]
mod tests {
mod test {
use super::parse_logging_spec;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/liblog/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ fn init() {
}

#[cfg(test)]
mod tests {
mod test {
use super::enabled;
use directive::LogDirective;

Expand Down
2 changes: 1 addition & 1 deletion src/librand/distributions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ fn ziggurat<R: Rng, P, Z>(
}

#[cfg(test)]
mod tests {
mod test {
use std::prelude::v1::*;

use {Rng, Rand};
Expand Down
2 changes: 1 addition & 1 deletion src/librand/distributions/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl IndependentSample<f64> for LogNormal {
}

#[cfg(test)]
mod tests {
mod test {
use std::prelude::v1::*;

use distributions::{Sample, IndependentSample};
Expand Down
2 changes: 1 addition & 1 deletion src/librand/distributions/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ float_impl! { f32 }
float_impl! { f64 }

#[cfg(test)]
mod tests {
mod test {
use std::num::Int;
use std::prelude::v1::*;
use distributions::{Sample, IndependentSample};
Expand Down
2 changes: 1 addition & 1 deletion src/librand/rand_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<T:Rand> Rand for Option<T> {
}

#[cfg(test)]
mod tests {
mod test {
use std::rand::{Rng, thread_rng, Open01, Closed01};

struct ConstantRng(u64);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static H256: [u32; 8] = [
];

#[cfg(test)]
mod tests {
mod test {
#![allow(deprecated)]
extern crate rand;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_bitflags/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ mod core {

#[cfg(test)]
#[allow(non_upper_case_globals)]
mod tests {
mod test {
use std::hash::{self, SipHasher};
use std::option::Option::{Some, None};

Expand Down
2 changes: 1 addition & 1 deletion src/libserialize/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl FromHex for str {
}

#[cfg(test)]
mod tests {
mod test {
extern crate test;
use self::test::Bencher;
use hex::{FromHex, ToHex};
Expand Down
2 changes: 1 addition & 1 deletion src/libserialize/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2610,7 +2610,7 @@ impl FromStr for Json {
}

#[cfg(test)]
mod tests {
mod test {
extern crate test;
use self::Animal::*;
use self::DecodeEnum::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static ASCII_UPPERCASE_MAP: [u8; 256] = [


#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use super::*;
use char::from_u32;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ mod arch {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl IntoBytes for Vec<u8> {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use super::*;
use libc;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions) -> io::Result
}

#[cfg(test)]
mod tests {
mod test {
#![allow(deprecated)] //rand

use prelude::v1::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ impl<S: Write> fmt::Debug for BufStream<S> where S: fmt::Debug {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use io::prelude::*;
use io::{self, BufReader, BufWriter, BufStream, Cursor, LineWriter};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Write for Cursor<Vec<u8>> {


#[cfg(test)]
mod tests {
mod test {
use core::prelude::*;

use io::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl Write for Vec<u8> {
}

#[cfg(test)]
mod tests {
mod test {
use io::prelude::*;
use vec::Vec;
use test;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ impl<B: BufRead> Iterator for Lines<B> {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use io::prelude::*;
use io;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use io;
use net::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ impl AsInner<net_imp::TcpListener> for TcpListener {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;

use io::ErrorKind;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl AsInner<net_imp::UdpSocket> for UdpSocket {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;

use io::ErrorKind;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ pub fn to_str_exp_digits(num: f32, dig: usize, upper: bool) -> String {
}

#[cfg(test)]
mod tests {
mod test {
use f32::*;
use num::*;
use num::FpCategory as Fp;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ pub fn to_str_exp_digits(num: f64, dig: usize, upper: bool) -> String {
}

#[cfg(test)]
mod tests {
mod test {
use f64::*;
use num::*;
use num::FpCategory as Fp;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ pub fn test_num<T>(ten: T, two: T) where
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use super::*;
use i8;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/strconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ const DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11;
const DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;

#[cfg(test)]
mod tests {
mod test {
use core::num::wrapping::WrappingOps;
use string::ToString;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
macro_rules! uint_module { ($T:ty) => (

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;
use num::FromStrRadix;

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/net/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl sys_common::AsInner<UnixAcceptorImp> for UnixAcceptor {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;

use old_io::fs::PathExtensions;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ impl Drop for Process {
}

#[cfg(test)]
mod tests {
mod test {
use old_io::{Truncate, Write, TimedOut, timer, process, FileNotFound};
use old_io::{Reader, Writer};
use prelude::v1::{Ok, Err, drop, Some, None, Vec};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl Writer for StdWriter {
}

#[cfg(test)]
mod tests {
mod test {
use prelude::v1::*;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_path/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ static dot_static: &'static [u8] = b".";
static dot_dot_static: &'static [u8] = b"..";

#[cfg(test)]
mod tests {
mod test {
use super::*;

use clone::Clone;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/old_path/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ fn prefix_len(p: Option<PathPrefix>) -> usize {
}

#[cfg(test)]
mod tests {
mod test {
use super::PathPrefix::*;
use super::parse_prefix;
use super::*;
Expand Down
Loading