1
Fork 0

Adding missing imports for tests, and gate off others

This commit is contained in:
Alex Crichton 2013-02-28 11:57:33 -05:00
parent bc3bee410a
commit cb4ab76e4a
46 changed files with 141 additions and 109 deletions

View file

@ -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))
}
}

View file

@ -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]

View file

@ -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,

View file

@ -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);
};

View file

@ -14,6 +14,7 @@ Functions for the unit type.
*/
#[cfg(notest)]
use cmp::{Eq, Ord};
#[cfg(notest)]

View file

@ -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(

View file

@ -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};

View file

@ -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};

View file

@ -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};

View file

@ -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;

View file

@ -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]

View file

@ -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> {

View file

@ -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 {

View file

@ -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();

View file

@ -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);

View file

@ -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};

View file

@ -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
*/

View file

@ -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;

View file

@ -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;

View file

@ -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.

View file

@ -25,6 +25,8 @@ do || {
use ops::Drop;
#[cfg(test)] use task::failing;
pub trait Finally<T> {
fn finally(&self, dtor: &fn()) -> T;
}

View file

@ -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);

View file

@ -103,6 +103,7 @@ pub fn unreachable() -> ! {
#[cfg(test)]
mod tests {
use option::{None, Some};
use util::{NonCopyable, id, replace, swap};
#[test]

View file

@ -208,6 +208,8 @@ mod test {
use back::rpath::{get_relative_to, get_rpath_relative_to_output};
#[cfg(test)]
use back::rpath::{minimize_rpaths, rpaths_to_flags};
#[cfg(test)]
use driver::session;
#[test]
pub fn test_rpaths_to_flags() {

View file

@ -344,13 +344,10 @@ pub fn sess_os_to_meta_os(os: os) -> metadata::loader::os {
#[cfg(test)]
pub mod test {
use core::prelude::*;
use driver::session::{bin_crate, building_library, lib_crate};
use driver::session::{unknown_crate};
use syntax::ast;
use syntax::ast_util;
use syntax::codemap;
pub fn make_crate_type_attr(+t: ~str) -> ast::attribute {

View file

@ -41,6 +41,9 @@ use syntax::fold;
use syntax;
use writer = std::ebml::writer;
#[cfg(test)] use syntax::parse;
#[cfg(test)] use syntax::print::pprust;
// Auxiliary maps of things to be encoded
pub struct Maps {
mutbl_map: middle::borrowck::mutbl_map,
@ -1226,6 +1229,8 @@ fn mk_ctxt() -> fake_ext_ctxt {
#[cfg(test)]
fn roundtrip(in_item: Option<@ast::item>) {
use std::prettyprint;
let in_item = in_item.get();
let bytes = do io::with_bytes_writer |wr| {
let ebml_w = writer::Encoder(wr);

View file

@ -34,10 +34,8 @@ mod test {
pub fn parse_attributes(source: ~str) -> ~[ast::attribute] {
use syntax::parse;
use syntax::parse::parser;
use syntax::parse::attr::parser_attr;
use syntax::codemap;
use syntax::diagnostic;
let parse_sess = syntax::parse::new_parse_sess(None);
let parser = parse::new_parser_from_source_str(

View file

@ -11,6 +11,8 @@
use core::prelude::*;
use doc;
#[cfg(test)] use extract;
#[cfg(test)] use parse;
use core::vec;

View file

@ -22,6 +22,10 @@ use markdown_writer::WriterFactory;
use pass::Pass;
use sort_pass;
#[cfg(test)] use config;
#[cfg(test)] use markdown_writer;
#[cfg(test)] use page_pass;
use core::cell::Cell;
use core::str;
use core::vec;

View file

@ -220,7 +220,7 @@ pub fn make_filename(
#[test]
fn should_use_markdown_file_name_based_off_crate() {
let config = Config {
let config = config::Config {
output_dir: Path("output/dir"),
output_format: config::Markdown,
output_style: config::DocPerCrate,
@ -234,7 +234,7 @@ fn should_use_markdown_file_name_based_off_crate() {
#[test]
fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
let config = Config {
let config = config::Config {
output_dir: Path("output/dir"),
output_format: config::PandocHtml,
output_style: config::DocPerMod,
@ -248,7 +248,7 @@ fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
#[test]
fn should_name_mod_file_names_by_path() {
let config = Config {
let config = config::Config {
output_dir: Path("output/dir"),
output_format: config::PandocHtml,
output_style: config::DocPerMod,

View file

@ -14,6 +14,8 @@ use astsrv;
use doc;
use time;
#[cfg(test)] use extract;
use core::vec;
/// A single operation on the document model

View file

@ -19,6 +19,8 @@ use fold::Fold;
use fold;
use pass::Pass;
#[cfg(test)] use extract;
use syntax::ast;
pub fn mk_pass() -> Pass {

View file

@ -63,6 +63,8 @@ fn is_hidden(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool {
#[test]
fn should_prune_hidden_items() {
use core::vec;
let doc = test::mk_doc(~"#[doc(hidden)] mod a { }");
assert vec::is_empty(doc.cratemod().mods())
}

View file

@ -24,6 +24,9 @@ pub fn mk_pass() -> Pass {
#[test]
fn test() {
use astsrv;
use extract;
let source = ~"mod z { } fn y() { }";
do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");

View file

@ -38,6 +38,9 @@ pub fn mk_pass() -> Pass {
#[test]
fn test() {
use astsrv;
use extract;
let source =
~"mod imod { } \
extern mod inmod {

View file

@ -17,6 +17,8 @@ use fold;
use pass::Pass;
use util::NominalOp;
#[cfg(test)] use extract;
use std::sort;
pub type ItemLtEqOp = @pure fn(v1: &doc::ItemTag, v2: &doc::ItemTag) -> bool;

View file

@ -26,6 +26,8 @@ pub fn mk_pass() -> Pass {
#[test]
fn should_trim_text() {
use core::option::Some;
let doc = test::mk_doc(~"#[doc = \" desc \"] \
mod m {
}");

View file

@ -273,7 +273,7 @@ pub impl &Arena {
#[test]
fn test_arena_destructors() {
let arena = arena::Arena();
let arena = Arena();
for uint::range(0, 10) |i| {
// Arena allocate something with drop glue to make sure it
// doesn't leak.
@ -286,7 +286,7 @@ fn test_arena_destructors() {
#[test] #[should_fail] #[ignore(cfg(windows))]
fn test_arena_destructors_fail() {
let arena = arena::Arena();
let arena = Arena();
// Put some stuff in the arena.
for uint::range(0, 10) |i| {
// Arena allocate something with drop glue to make sure it

View file

@ -635,8 +635,8 @@ mod test {
use flatpipes::pod;
use flatpipes::serial;
use io_util::BufReader;
use net::tcp::TcpSocketBuf;
use flatpipes::{BytePort, FlatChan, FlatPort};
use net::tcp::TcpSocketBuf;
use core::int;
use core::io::{BytesReader, BytesWriter};
@ -762,7 +762,6 @@ mod test {
use core::cell::Cell;
use net::ip;
use net::tcp::TcpSocket;
use net::tcp;
use uv;

View file

@ -639,7 +639,6 @@ pub mod groups {
mod tests {
use core::prelude::*;
use opt = getopts;
use getopts::groups::OptGroup;
use getopts::*;

View file

@ -819,7 +819,6 @@ mod tests {
use net_url::*;
use core::hashmap::linear::LinearMap;
use core::str;
#[test]
pub fn test_url_parse() {

View file

@ -1334,15 +1334,15 @@ pub enum inlined_item {
#[cfg(test)]
mod test {
use std;
use codemap::*;
use super::*;
//are asts encodable?
// it looks like this *will* be a compiler bug, after
// I get deriving_eq for crates into incoming :)
/*
use std;
use codemap::*;
use super::*;
#[test] fn check_asts_encodable() {
let bogus_span = span {lo:BytePos(10),
hi:BytePos(20),

View file

@ -1206,14 +1206,7 @@ fn mk_enum_deser_body(
mod test {
use std::serialize::Encodable;
use std::serialize::Encoder;
use core::dvec::*;
use util::testing::*;
use core::io;
use core::str;
use core::option::Option;
use core::option::Some;
use core::option::None;
use std;
// just adding the ones I want to test, for now:
#[deriving_eq]

View file

@ -500,7 +500,6 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
#[cfg(test)]
mod test {
use super::*;
use super::MapChain;
use util::testing::check_equal;
use core::hashmap::linear::LinearMap;

View file

@ -10,7 +10,6 @@
use core::prelude::*;
use ast::tt_delim;
use ast;
use codemap::span;
use ext::base::ext_ctxt;

View file

@ -779,7 +779,6 @@ pub mod test {
use core::option::None;
use diagnostic;
use parse::token;
use util::interner;
use util::testing::{check_equal, check_equal_ptr};
// represents a testing reader (incl. both reader and interner)