1
Fork 0

test: Update tests and import the prelude in some more places.

This commit is contained in:
Patrick Walton 2013-05-21 17:24:31 -07:00
parent 1be40be613
commit ee52865c88
29 changed files with 66 additions and 43 deletions

View file

@ -511,6 +511,7 @@ pub impl<'self, T:Const + Owned> RWReadMode<'self, T> {
#[cfg(test)]
mod tests {
use core::prelude::*;
use arc::*;
use arc;

View file

@ -534,6 +534,8 @@ impl<T> BaseIter<T> for @mut DList<T> {
#[cfg(test)]
mod tests {
use core::prelude::*;
use super::*;
#[test]

View file

@ -405,6 +405,8 @@ pub fn input_vec_state(files: ~[Option<Path>],
#[cfg(test)]
mod test {
use core::prelude::*;
use core::io::WriterUtil;
use super::{FileInput, pathify, input_vec, input_vec_state};

View file

@ -866,6 +866,8 @@ mod test {
// Tests that the different backends behave the same when the
// binary streaming protocol is broken
mod broken_protocol {
use core::prelude::*;
use flatpipes::{BytePort, FlatPort};
use flatpipes::flatteners::PodUnflattener;
use flatpipes::pod;

View file

@ -1327,6 +1327,8 @@ impl to_str::ToStr for Error {
#[cfg(test)]
mod tests {
use core::prelude::*;
use super::*;
use core::hashmap::HashMap;

View file

@ -1440,6 +1440,8 @@ struct TcpBufferedSocketData {
#[cfg(test)]
mod test {
use core::prelude::*;
use net::ip;
use net::tcp::{GenericListenErr, TcpConnectErrData, TcpListenErrData};
use net::tcp::{connect, accept, read, listen, TcpSocket, socket_buf};

View file

@ -1145,6 +1145,8 @@ pub impl BigInt {
#[cfg(test)]
mod biguint_tests {
use core::prelude::*;
use super::*;
use core::num::{IntConvertible, Zero, One, FromStrRadix};
use core::cmp::{Less, Equal, Greater};
@ -1611,6 +1613,8 @@ mod biguint_tests {
#[cfg(test)]
mod bigint_tests {
use core::prelude::*;
use super::*;
use core::cmp::{Less, Equal, Greater};
use core::num::{IntConvertible, Zero, One, FromStrRadix};

View file

@ -284,6 +284,8 @@ impl<T: FromStrRadix + Clone + Integer + Ord>
#[cfg(test)]
mod test {
use core::prelude::*;
use super::*;
use core::num::{Zero,One,FromStrRadix,IntConvertible};
use core::from_str::FromStr;

View file

@ -185,13 +185,13 @@ pub impl <T:Ord> PriorityQueue<T> {
mod tests {
use sort::merge_sort;
use core::cmp::le;
use priority_queue::PriorityQueue::{from_vec, new};
use priority_queue::PriorityQueue;
#[test]
fn test_top_and_pop() {
let data = ~[2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
let mut sorted = merge_sort(data, le);
let mut heap = from_vec(data);
let mut heap = PriorityQueue::from_vec(data);
while !heap.is_empty() {
assert_eq!(heap.top(), sorted.last());
assert_eq!(heap.pop(), sorted.pop());
@ -200,7 +200,7 @@ mod tests {
#[test]
fn test_push() {
let mut heap = from_vec(~[2, 4, 9]);
let mut heap = PriorityQueue::from_vec(~[2, 4, 9]);
assert_eq!(heap.len(), 3);
assert!(*heap.top() == 9);
heap.push(11);
@ -222,7 +222,7 @@ mod tests {
#[test]
fn test_push_unique() {
let mut heap = from_vec(~[~2, ~4, ~9]);
let mut heap = PriorityQueue::from_vec(~[~2, ~4, ~9]);
assert_eq!(heap.len(), 3);
assert!(*heap.top() == ~9);
heap.push(~11);
@ -244,7 +244,7 @@ mod tests {
#[test]
fn test_push_pop() {
let mut heap = from_vec(~[5, 5, 2, 1, 3]);
let mut heap = PriorityQueue::from_vec(~[5, 5, 2, 1, 3]);
assert_eq!(heap.len(), 5);
assert_eq!(heap.push_pop(6), 6);
assert_eq!(heap.len(), 5);
@ -258,7 +258,7 @@ mod tests {
#[test]
fn test_replace() {
let mut heap = from_vec(~[5, 5, 2, 1, 3]);
let mut heap = PriorityQueue::from_vec(~[5, 5, 2, 1, 3]);
assert_eq!(heap.len(), 5);
assert_eq!(heap.replace(6), 5);
assert_eq!(heap.len(), 5);
@ -271,7 +271,7 @@ mod tests {
}
fn check_to_vec(data: ~[int]) {
let heap = from_vec(copy data);
let heap = PriorityQueue::from_vec(copy data);
assert_eq!(merge_sort((copy heap).to_vec(), le), merge_sort(data, le));
assert_eq!(heap.to_sorted_vec(), merge_sort(data, le));
}
@ -296,27 +296,27 @@ mod tests {
#[test]
#[should_fail]
#[ignore(cfg(windows))]
fn test_empty_pop() { let mut heap = new::<int>(); heap.pop(); }
fn test_empty_pop() { let mut heap = PriorityQueue::new::<int>(); heap.pop(); }
#[test]
fn test_empty_maybe_pop() {
let mut heap = new::<int>();
let mut heap = PriorityQueue::new::<int>();
assert!(heap.maybe_pop().is_none());
}
#[test]
#[should_fail]
#[ignore(cfg(windows))]
fn test_empty_top() { let empty = new::<int>(); empty.top(); }
fn test_empty_top() { let empty = PriorityQueue::new::<int>(); empty.top(); }
#[test]
fn test_empty_maybe_top() {
let empty = new::<int>();
let empty = PriorityQueue::new::<int>();
assert!(empty.maybe_top().is_none());
}
#[test]
#[should_fail]
#[ignore(cfg(windows))]
fn test_empty_replace() { let mut heap = new(); heap.replace(5); }
fn test_empty_replace() { let mut heap = PriorityQueue::new(); heap.replace(5); }
}

View file

@ -267,6 +267,8 @@ pub impl SmallIntSet {
#[cfg(test)]
mod tests {
use core::prelude::*;
use super::SmallIntMap;
#[test]

View file

@ -746,6 +746,8 @@ fn shift_vec<T:Copy>(dest: &mut [T],
#[cfg(test)]
mod test_qsort3 {
use core::prelude::*;
use sort::*;
use core::vec;
@ -788,6 +790,8 @@ mod test_qsort3 {
#[cfg(test)]
mod test_qsort {
use core::prelude::*;
use sort::*;
use core::int;
@ -852,6 +856,7 @@ mod test_qsort {
#[cfg(test)]
mod tests {
use core::prelude::*;
use sort::*;
@ -920,6 +925,8 @@ mod tests {
#[cfg(test)]
mod test_tim_sort {
use core::prelude::*;
use sort::tim_sort;
use core::rand::RngUtil;
@ -1011,6 +1018,8 @@ mod test_tim_sort {
#[cfg(test)]
mod big_tests {
use core::prelude::*;
use sort::*;
use core::rand::RngUtil;

View file

@ -36,6 +36,8 @@ extern mod core(name = "std", vers = "0.7-pre");
use core::{str, unstable};
use core::str::{StrSlice, OwnedStr};
pub use core::os;
pub mod uv_ll;
// General io and system-services modules

View file

@ -711,6 +711,7 @@ pub impl<'self> RWlockReadMode<'self> {
#[cfg(test)]
mod tests {
use core::prelude::*;
use sync::*;

View file

@ -27,6 +27,8 @@ pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
#[cfg(test)]
mod tests {
use core::prelude::*;
use tempfile::mkdtemp;
use tempfile;
use core::os;

View file

@ -175,6 +175,8 @@ extern fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) {
#[cfg(test)]
mod test {
use core::prelude::*;
use timer::*;
use uv;
use core::cell::Cell;

View file

@ -699,6 +699,8 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
#[cfg(test)]
mod test_treemap {
use core::prelude::*;
use core::iterator::*;
use super::*;
use core::rand::RngUtil;
@ -1017,6 +1019,7 @@ mod test_treemap {
#[cfg(test)]
mod test_set {
use core::prelude::*;
use core::iterator::*;
use super::*;

View file

@ -1224,6 +1224,7 @@ pub unsafe fn addrinfo_as_sockaddr_in6(input: *addrinfo) -> *sockaddr_in6 {
#[cfg(test)]
mod test {
use core::prelude::*;
use core::comm::{SharedChan, stream, GenericChan, GenericPort};
use super::*;

View file

@ -15,9 +15,7 @@
pub mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -10,7 +10,7 @@
extern fn foo() {}
static x: extern "C" fn() = foo;
static x: *u8 = foo;
static y: *libc::c_void = x as *libc::c_void;
static a: &'static int = &10;
static b: *int = a as *int;

View file

@ -13,7 +13,7 @@
extern mod cci_const;
use cci_const::bar;
static foo: extern "C" fn() = bar;
static foo: *u8 = bar;
pub fn main() {
assert_eq!(foo, cci_const::bar);

View file

@ -10,7 +10,7 @@
extern fn foopy() {}
static f: extern "C" fn() = foopy;
static f: *u8 = foopy;
static s: S = S { f: foopy };
struct S {

View file

@ -10,9 +10,7 @@
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -10,9 +10,7 @@
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -14,9 +14,7 @@
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -10,9 +10,7 @@
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -13,9 +13,7 @@
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -15,10 +15,10 @@ extern fn g() {
}
pub fn main() {
// extern functions are extern function types
let a: extern "C" fn() = f;
let b: extern "C" fn() = f;
let c: extern "C" fn() = g;
// extern functions are *u8 types
let a: *u8 = f;
let b: *u8 = f;
let c: *u8 = g;
assert_eq!(a, b);
assert!(a != c);

View file

@ -10,9 +10,7 @@
mod rustrt {
pub extern {
pub fn rust_dbg_call(cb: extern "C" fn(data: libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t)
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
}
}

View file

@ -1,9 +1,7 @@
use std::unstable::run_in_bare_thread;
extern {
pub fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t)
-> libc::uintptr_t,
data: libc::uintptr_t) -> libc::uintptr_t;
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t) -> libc::uintptr_t;
}
pub fn main() {