Fix tests.

This commit is contained in:
Josh Matthews 2014-04-04 18:32:40 -04:00
parent ebc51c268a
commit 4b8254f32b
11 changed files with 43 additions and 40 deletions

View file

@ -71,8 +71,9 @@ fn assert_parse(url: &'static str,
charset: Option<~str>,
data: Option<~[u8]>) {
use std::from_str::FromStr;
use std::comm;
let (start_port, start_chan) = Chan::new();
let (start_chan, start_port) = comm::channel();
load(FromStr::from_str(url).unwrap(), start_chan);
let response = start_port.recv();

View file

@ -501,6 +501,7 @@ mod tests {
use resource_task::{ResourceTask, Metadata, start_sending};
use image::base::test_image_bin;
use servo_util::url::parse_url;
use std::comm;
use std::comm::{Empty, Data, Disconnected};
fn mock_resource_task(on_load: proc(resource: Sender<resource_task::ProgressMsg>)) -> ResourceTask {
@ -561,7 +562,7 @@ mod tests {
#[test]
fn should_not_request_url_from_resource_task_on_multiple_prefetches() {
let (url_requested, url_requested_chan) = Chan::new();
let (url_requested_chan, url_requested) = comm::channel();
let mock_resource_task = mock_resource_task(proc(response) {
url_requested_chan.send(());
@ -584,7 +585,7 @@ mod tests {
#[test]
fn should_return_image_not_ready_if_data_has_not_arrived() {
let (wait_port, wait_chan) = Chan::new();
let (wait_chan, wait_port) = comm::channel();
let mock_resource_task = mock_resource_task(proc(response) {
// Don't send the data until after the client requests
@ -599,7 +600,7 @@ mod tests {
image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(url.clone()));
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url, response_chan));
assert!(response_port.recv() == ImageNotReady);
wait_chan.send(());
@ -625,7 +626,7 @@ mod tests {
// Wait until our mock resource task has sent the image to the image cache
join_port.recv();
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageReady(_) => (),
@ -655,7 +656,7 @@ mod tests {
join_port.recv();
for _ in range(0,2) {
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url.clone(), response_chan));
match response_port.recv() {
ImageReady(_) => (),
@ -669,9 +670,9 @@ mod tests {
#[test]
fn should_not_request_image_from_resource_task_if_image_is_already_available() {
let (image_bin_sent, image_bin_sent_chan) = Chan::new();
let (image_bin_sent_chan, image_bin_sent) = comm::channel();
let (resource_task_exited, resource_task_exited_chan) = Chan::new();
let (resource_task_exited_chan, resource_task_exited) = comm::channel();
let mock_resource_task = spawn_listener(proc(port: Receiver<resource_task::ControlMsg>) {
loop {
@ -715,9 +716,9 @@ mod tests {
#[test]
fn should_not_request_image_from_resource_task_if_image_fetch_already_failed() {
let (image_bin_sent, image_bin_sent_chan) = Chan::new();
let (image_bin_sent_chan, image_bin_sent) = comm::channel();
let (resource_task_exited, resource_task_exited_chan) = Chan::new();
let (resource_task_exited_chan, resource_task_exited) = comm::channel();
let mock_resource_task = spawn_listener(proc(port: Receiver<resource_task::ControlMsg>) {
loop {
@ -780,7 +781,7 @@ mod tests {
// Wait until our mock resource task has sent the image to the image cache
join_port.recv();
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageFailed => (),
@ -810,7 +811,7 @@ mod tests {
// Wait until our mock resource task has sent the image to the image cache
join_port.recv();
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url.clone(), response_chan));
match response_port.recv() {
ImageFailed => (),
@ -818,7 +819,7 @@ mod tests {
}
// And ask again, we should get the same response
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageFailed => (),
@ -849,7 +850,7 @@ mod tests {
join_port.recv();
// Make the request
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
@ -879,7 +880,7 @@ mod tests {
// Wait until our mock resource task has sent the image to the image cache
join_port.recv();
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(WaitForImage(url, response_chan));
match response_port.recv() {
ImageReady(..) => (),
@ -892,7 +893,7 @@ mod tests {
#[test]
fn should_return_image_on_wait_if_image_is_not_yet_loaded() {
let (wait_port, wait_chan) = Chan::new();
let (wait_chan, wait_port) = comm::channel();
let mock_resource_task = mock_resource_task(proc(response) {
wait_port.recv();
@ -906,7 +907,7 @@ mod tests {
image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(url.clone()));
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(WaitForImage(url, response_chan));
wait_chan.send(());
@ -922,7 +923,7 @@ mod tests {
#[test]
fn should_return_image_failed_on_wait_if_image_fails_to_load() {
let (wait_port, wait_chan) = Chan::new();
let (wait_chan, wait_port) = comm::channel();
let mock_resource_task = mock_resource_task(proc(response) {
wait_port.recv();
@ -936,7 +937,7 @@ mod tests {
image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(url.clone()));
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(WaitForImage(url, response_chan));
wait_chan.send(());
@ -963,7 +964,7 @@ mod tests {
image_cache_task.send(Prefetch(url.clone()));
image_cache_task.send(Decode(url.clone()));
let (response_port, response_chan) = Chan::new();
let (response_chan, response_port) = comm::channel();
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageReady(_) => (),

View file

@ -75,7 +75,7 @@ pub struct LoadResponse {
}
/// Messages sent in response to a `Load` message
#[deriving(Eq)]
#[deriving(Eq,Show)]
pub enum ProgressMsg {
/// Binary data - there may be multiple of these
Payload(~[u8]),

View file

@ -600,8 +600,8 @@ mod tests {
#[test]
fn test_parsing() {
assert_eq!(parse(""), None)
assert_eq!(parse("e"), Some(~[Selector{
assert!(parse("") == None)
assert!(parse("e") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[LocalNameSelector(~"e")],
next: None,
@ -609,7 +609,7 @@ mod tests {
pseudo_element: None,
specificity: specificity(0, 0, 1),
}]))
assert_eq!(parse(".foo"), Some(~[Selector{
assert!(parse(".foo") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[ClassSelector(~"foo")],
next: None,
@ -617,7 +617,7 @@ mod tests {
pseudo_element: None,
specificity: specificity(0, 1, 0),
}]))
assert_eq!(parse("#bar"), Some(~[Selector{
assert!(parse("#bar") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[IDSelector(~"bar")],
next: None,
@ -625,7 +625,7 @@ mod tests {
pseudo_element: None,
specificity: specificity(1, 0, 0),
}]))
assert_eq!(parse("e.foo#bar"), Some(~[Selector{
assert!(parse("e.foo#bar") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[LocalNameSelector(~"e"),
ClassSelector(~"foo"),
@ -635,7 +635,7 @@ mod tests {
pseudo_element: None,
specificity: specificity(1, 1, 1),
}]))
assert_eq!(parse("e.foo #bar"), Some(~[Selector{
assert!(parse("e.foo #bar") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[IDSelector(~"bar")],
next: Some((~CompoundSelector {
@ -650,7 +650,7 @@ mod tests {
// Default namespace does not apply to attribute selectors
// https://github.com/mozilla/servo/pull/1652
let mut namespaces = NamespaceMap::new();
assert_eq!(parse_ns("[Foo]", &namespaces), Some(~[Selector{
assert!(parse_ns("[Foo]", &namespaces) == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[AttrExists(AttrSelector {
name: ~"Foo",
@ -665,7 +665,7 @@ mod tests {
// Default namespace does not apply to attribute selectors
// https://github.com/mozilla/servo/pull/1652
namespaces.default = Some(namespace::MathML);
assert_eq!(parse_ns("[Foo]", &namespaces), Some(~[Selector{
assert!(parse_ns("[Foo]", &namespaces) == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[AttrExists(AttrSelector {
name: ~"Foo",
@ -678,7 +678,7 @@ mod tests {
specificity: specificity(0, 1, 0),
}]))
// Default namespace does apply to type selectors
assert_eq!(parse_ns("e", &namespaces), Some(~[Selector{
assert!(parse_ns("e", &namespaces) == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[
NamespaceSelector(namespace::MathML),
@ -690,7 +690,7 @@ mod tests {
specificity: specificity(0, 0, 1),
}]))
// https://github.com/mozilla/servo/issues/1723
assert_eq!(parse("::before"), Some(~[Selector{
assert!(parse("::before") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[],
next: None,
@ -698,7 +698,7 @@ mod tests {
pseudo_element: Some(Before),
specificity: specificity(0, 0, 1),
}]))
assert_eq!(parse("div :after"), Some(~[Selector{
assert!(parse("div :after") == Some(~[Selector{
compound_selectors: Arc::new(CompoundSelector {
simple_selectors: ~[],
next: Some((~CompoundSelector {

View file

@ -484,13 +484,14 @@ impl<'a,K,V> Iterator<(&'a K, &'a V)> for ConcurrentHashMapIterator<'a,K,V> {
pub mod test {
use sync::Arc;
use native;
use std::comm;
use concurrentmap::ConcurrentHashMap;
#[test]
pub fn smoke() {
let m = Arc::new(ConcurrentHashMap::new());
let (port, chan) = Chan::new();
let (chan, port) = comm::channel();
// Big enough to make it resize once.
for i in range(0, 5) {

View file

@ -79,8 +79,8 @@ pub fn quicksort<T:Ord + Eq>(arr: &mut [T]) {
#[cfg(test)]
pub mod test {
use std::rand::{Rng, task_rng};
use std::rand;
use rand;
use rand::{Rng, task_rng};
use sort;

@ -1 +1 @@
Subproject commit 6a1086270b00531c6551c9d0aa660a6aff435f87
Subproject commit 1c69b99054546d4313d7d56e2e29e3facd57bd66

@ -1 +1 @@
Subproject commit 189a70d6c748a376540ce679530e6d8f317b198c
Subproject commit e7b18f168861584f0a59d5c9a09b7766c721a823

@ -1 +1 @@
Subproject commit 79831beec751932d691bdfe93ed464debec00e51
Subproject commit fa82ccf83a38cbcbbeb1036e080bf7c170309ee0

@ -1 +1 @@
Subproject commit 4891b380a54f163d73323be53f9e614b4cf3527c
Subproject commit e06e4633bd3a90c644bafdaa8da8cf57472e5e26

@ -1 +1 @@
Subproject commit 0b2b368ac6599667ac508916ea4fd5193490dfd6
Subproject commit f81f450ba6a742041844d40154dfe8ad1e540a46