Fix tests for new last-use behavior

This commit is contained in:
Brian Anderson 2012-10-20 20:58:15 -07:00
parent a2152edf90
commit 73ea922d6b
8 changed files with 56 additions and 56 deletions

View file

@ -100,8 +100,8 @@ mod test {
#[test] #[test]
fn should_match_font_sizes() { fn should_match_font_sizes() {
let input = ~"* {font-size:12px; font-size:inherit; font-size:200%; font-size:x-small}"; let input = ~"* {font-size:12px; font-size:inherit; font-size:200%; font-size:x-small}";
let token_port = spawn_css_lexer_from_string(input); let token_port = spawn_css_lexer_from_string(move input);
let _actual_rule = build_stylesheet(token_port); let _actual_rule = build_stylesheet(move token_port);
let _expected_rule : Stylesheet = ~[~(~[~Element(~"*", ~[])], let _expected_rule : Stylesheet = ~[~(~[~Element(~"*", ~[])],
~[FontSize(Specified(LengthSize(Px(12.0)))), ~[FontSize(Specified(LengthSize(Px(12.0)))),
FontSize(Specified(PercentSize(100.0))), FontSize(Specified(PercentSize(100.0))),
@ -115,8 +115,8 @@ mod test {
#[test] #[test]
fn should_match_width_height() { fn should_match_width_height() {
let input = ~"* {width:20%; height:auto; width:20px; width:3in; height:70px; height:30px}"; let input = ~"* {width:20%; height:auto; width:20px; width:3in; height:70px; height:30px}";
let token_port = spawn_css_lexer_from_string(input); let token_port = spawn_css_lexer_from_string(move input);
let _actual_rule = build_stylesheet(token_port); let _actual_rule = build_stylesheet(move token_port);
let _expected_rule : Stylesheet = ~[~(~[~Element(~"*", ~[])], let _expected_rule : Stylesheet = ~[~(~[~Element(~"*", ~[])],
~[Width(Specified(BoxPercent(20.0))), ~[Width(Specified(BoxPercent(20.0))),
Height(Specified(BoxAuto)), Height(Specified(BoxAuto)),

View file

@ -234,9 +234,9 @@ mod test {
#[allow(non_implicitly_copyable_typarams)] #[allow(non_implicitly_copyable_typarams)]
fn new_node_from_attr(scope: &NodeScope, name: ~str, val: ~str) -> Node { fn new_node_from_attr(scope: &NodeScope, name: ~str, val: ~str) -> Node {
let elmt = ElementData(~"div", ~HTMLDivElement); let elmt = ElementData(~"div", ~HTMLDivElement);
let attr = ~Attr(name, val); let attr = ~Attr(move name, move val);
elmt.attrs.push(attr); elmt.attrs.push(move attr);
return scope.new_node(dom::node::Element(elmt)); return scope.new_node(dom::node::Element(move elmt));
} }
#[test] #[test]
@ -246,7 +246,7 @@ mod test {
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]); let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
assert node.matches_selector(~sel); assert node.matches_selector(~move sel);
} }
#[test] #[test]
@ -256,7 +256,7 @@ mod test {
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]); let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
assert node.matches_selector(~sel); assert node.matches_selector(~move sel);
} }
#[test] #[test]
@ -266,7 +266,7 @@ mod test {
let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]); let sel = Element(~"*", ~[StartsWith(~"lang", ~"en")]);
assert !node.matches_selector(~sel); assert !node.matches_selector(~move sel);
} }
#[test] #[test]
@ -276,7 +276,7 @@ mod test {
let sel = Element(~"div", ~[Includes(~"mad", ~"hatter")]); let sel = Element(~"div", ~[Includes(~"mad", ~"hatter")]);
assert node.matches_selector(~sel); assert node.matches_selector(~move sel);
} }
#[test] #[test]
@ -287,8 +287,8 @@ mod test {
let sel1 = Element(~"div", ~[Exists(~"mad")]); let sel1 = Element(~"div", ~[Exists(~"mad")]);
let sel2 = Element(~"div", ~[Exists(~"hatter")]); let sel2 = Element(~"div", ~[Exists(~"hatter")]);
assert node.matches_selector(~sel1); assert node.matches_selector(~move sel1);
assert !node.matches_selector(~sel2); assert !node.matches_selector(~move sel2);
} }
#[test] #[test]
@ -300,7 +300,7 @@ mod test {
let sel = Element(~"div", ~[Exact(~"mad", ~"hatter")]); let sel = Element(~"div", ~[Exact(~"mad", ~"hatter")]);
assert !node1.matches_selector(~copy sel); assert !node1.matches_selector(~copy sel);
assert node2.matches_selector(~sel); assert node2.matches_selector(~move sel);
} }
#[test] #[test]
@ -327,7 +327,7 @@ mod test {
assert child2.matches_selector(~copy sel1); assert child2.matches_selector(~copy sel1);
assert gchild.matches_selector(~copy sel1); assert gchild.matches_selector(~copy sel1);
assert ggchild.matches_selector(~copy sel1); assert ggchild.matches_selector(~copy sel1);
assert gggchild.matches_selector(~sel1); assert gggchild.matches_selector(~move sel1);
let sel2 = Descendant(~Child(~Element(~"*", ~[Exact(~"class", ~"blue")]), let sel2 = Descendant(~Child(~Element(~"*", ~[Exact(~"class", ~"blue")]),
~Element(~"*", ~[])), ~Element(~"*", ~[])),
@ -338,7 +338,7 @@ mod test {
assert !child2.matches_selector(~copy sel2); assert !child2.matches_selector(~copy sel2);
assert gchild.matches_selector(~copy sel2); assert gchild.matches_selector(~copy sel2);
assert ggchild.matches_selector(~copy sel2); assert ggchild.matches_selector(~copy sel2);
assert gggchild.matches_selector(~sel2); assert gggchild.matches_selector(~move sel2);
let sel3 = Sibling(~Element(~"*", ~[]), ~Element(~"*", ~[])); let sel3 = Sibling(~Element(~"*", ~[]), ~Element(~"*", ~[]));
@ -347,7 +347,7 @@ mod test {
assert child2.matches_selector(~copy sel3); assert child2.matches_selector(~copy sel3);
assert !gchild.matches_selector(~copy sel3); assert !gchild.matches_selector(~copy sel3);
assert !ggchild.matches_selector(~copy sel3); assert !ggchild.matches_selector(~copy sel3);
assert !gggchild.matches_selector(~sel3); assert !gggchild.matches_selector(~move sel3);
let sel4 = Descendant(~Child(~Element(~"*", ~[Exists(~"class")]), ~Element(~"*", ~[])), let sel4 = Descendant(~Child(~Element(~"*", ~[Exists(~"class")]), ~Element(~"*", ~[])),
~Element(~"*", ~[])); ~Element(~"*", ~[]));
@ -357,6 +357,6 @@ mod test {
assert !child2.matches_selector(~copy sel4); assert !child2.matches_selector(~copy sel4);
assert gchild.matches_selector(~copy sel4); assert gchild.matches_selector(~copy sel4);
assert ggchild.matches_selector(~copy sel4); assert ggchild.matches_selector(~copy sel4);
assert gggchild.matches_selector(~sel4); assert gggchild.matches_selector(~move sel4);
} }
} }

View file

@ -95,9 +95,9 @@ fn sanity_check() {
let dlist : DisplayList = DVec(); let dlist : DisplayList = DVec();
let render_layer = RenderLayer { display_list: move dlist, size: Size2D(800u, 600u) }; let render_layer = RenderLayer { display_list: move dlist, size: Size2D(800u, 600u) };
renderer.send(RenderMsg(render_layer)); renderer.send(RenderMsg(move render_layer));
let (exit_chan, exit_response_from_engine) = pipes::stream(); let (exit_chan, exit_response_from_engine) = pipes::stream();
renderer.send(render_task::ExitMsg(exit_chan)); renderer.send(render_task::ExitMsg(move exit_chan));
exit_response_from_engine.recv(); exit_response_from_engine.recv();
compositor.send(Exit) compositor.send(Exit)

View file

@ -518,7 +518,7 @@ fn should_fail_if_unprefetched_image_is_requested() {
let url = make_url(~"file", None); let url = make_url(~"file", None);
let (chan, port) = stream(); let (chan, port) = stream();
image_cache_task.send(GetImage(url, chan)); image_cache_task.send(GetImage(move url, move chan));
port.recv(); port.recv();
} }
@ -535,7 +535,7 @@ fn should_request_url_from_resource_task_on_prefetch() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(url)); image_cache_task.send(Prefetch(move url));
url_requested.recv(); url_requested.recv();
image_cache_task.exit(); image_cache_task.exit();
mock_resource_task.send(resource_task::Exit); mock_resource_task.send(resource_task::Exit);
@ -551,7 +551,7 @@ fn should_fail_if_requesting_decode_of_an_unprefetched_image() {
let image_cache_task = ImageCacheTask(mock_resource_task); let image_cache_task = ImageCacheTask(mock_resource_task);
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Decode(url)); image_cache_task.send(Decode(move url));
image_cache_task.exit(); image_cache_task.exit();
} }
@ -570,7 +570,7 @@ fn should_fail_if_requesting_image_before_requesting_decode() {
// no decode message // no decode message
let (chan, _port) = stream(); let (chan, _port) = stream();
image_cache_task.send(GetImage(url, chan)); image_cache_task.send(GetImage(move url, move chan));
image_cache_task.exit(); image_cache_task.exit();
mock_resource_task.send(resource_task::Exit); mock_resource_task.send(resource_task::Exit);
@ -590,7 +590,7 @@ fn should_not_request_url_from_resource_task_on_multiple_prefetches() {
let url = make_url(~"file", None); let url = make_url(~"file", None);
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(copy url));
image_cache_task.send(Prefetch(url)); image_cache_task.send(Prefetch(move url));
url_requested.recv(); url_requested.recv();
image_cache_task.exit(); image_cache_task.exit();
mock_resource_task.send(resource_task::Exit); mock_resource_task.send(resource_task::Exit);
@ -602,7 +602,7 @@ fn should_return_image_not_ready_if_data_has_not_arrived() {
let (wait_chan, wait_port) = pipes::stream(); let (wait_chan, wait_port) = pipes::stream();
let mock_resource_task = do mock_resource_task |response| { let mock_resource_task = do mock_resource_task |response, move wait_port| {
// Don't send the data until after the client requests // Don't send the data until after the client requests
// the image // the image
wait_port.recv(); wait_port.recv();
@ -616,7 +616,7 @@ fn should_return_image_not_ready_if_data_has_not_arrived() {
image_cache_task.send(Prefetch(copy url)); image_cache_task.send(Prefetch(copy url));
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(copy url));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
assert response_port.recv() == ImageNotReady; assert response_port.recv() == ImageNotReady;
wait_chan.send(()); wait_chan.send(());
image_cache_task.exit(); image_cache_task.exit();
@ -651,7 +651,7 @@ fn should_return_decoded_image_data_if_data_has_arrived() {
wait_for_image_chan.recv(); wait_for_image_chan.recv();
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageReady(_) => (), ImageReady(_) => (),
_ => fail _ => fail
@ -690,7 +690,7 @@ fn should_return_decoded_image_data_for_multiple_requests() {
for iter::repeat(2) { for iter::repeat(2) {
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(copy url, response_chan)); image_cache_task.send(GetImage(copy url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageReady(_) => (), ImageReady(_) => (),
_ => fail _ => fail
@ -822,7 +822,7 @@ fn should_return_failed_if_image_bin_cannot_be_fetched() {
wait_for_prefetech.recv(); wait_for_prefetech.recv();
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageFailed => (), ImageFailed => (),
_ => fail _ => fail
@ -861,7 +861,7 @@ fn should_return_failed_for_multiple_get_image_requests_if_image_bin_cannot_be_f
wait_for_prefetech.recv(); wait_for_prefetech.recv();
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(copy url, response_chan)); image_cache_task.send(GetImage(copy url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageFailed => (), ImageFailed => (),
_ => fail _ => fail
@ -869,7 +869,7 @@ fn should_return_failed_for_multiple_get_image_requests_if_image_bin_cannot_be_f
// And ask again, we should get the same response // And ask again, we should get the same response
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageFailed => (), ImageFailed => (),
_ => fail _ => fail
@ -889,7 +889,7 @@ fn should_return_not_ready_if_image_is_still_decoding() {
response.send(resource_task::Done(result::Ok(()))); response.send(resource_task::Done(result::Ok(())));
}; };
let wait_to_decode_port_cell = Cell(wait_to_decode_port); let wait_to_decode_port_cell = Cell(move wait_to_decode_port);
let decoder_factory = fn~(move wait_to_decode_port_cell) -> ~fn(&[u8]) -> Option<Image> { let decoder_factory = fn~(move wait_to_decode_port_cell) -> ~fn(&[u8]) -> Option<Image> {
let wait_to_decode_port = wait_to_decode_port_cell.take(); let wait_to_decode_port = wait_to_decode_port_cell.take();
fn~(data: &[u8], move wait_to_decode_port) -> Option<Image> { fn~(data: &[u8], move wait_to_decode_port) -> Option<Image> {
@ -899,7 +899,7 @@ fn should_return_not_ready_if_image_is_still_decoding() {
} }
}; };
let image_cache_task = ImageCacheTask_(mock_resource_task, decoder_factory); let image_cache_task = ImageCacheTask_(mock_resource_task, move decoder_factory);
let url = make_url(~"file", None); let url = make_url(~"file", None);
let wait_for_prefetech = Port(); let wait_for_prefetech = Port();
@ -920,7 +920,7 @@ fn should_return_not_ready_if_image_is_still_decoding() {
// Make the request // Make the request
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageNotReady => (), ImageNotReady => (),
@ -964,7 +964,7 @@ fn should_return_failed_if_image_decode_fails() {
// Make the request // Make the request
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageFailed => (), ImageFailed => (),
@ -1003,7 +1003,7 @@ fn should_return_image_on_wait_if_image_is_already_loaded() {
wait_for_decode.recv(); wait_for_decode.recv();
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(WaitForImage(url, response_chan)); image_cache_task.send(WaitForImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageReady(*) => (), ImageReady(*) => (),
_ => fail _ => fail
@ -1018,7 +1018,7 @@ fn should_return_image_on_wait_if_image_is_not_yet_loaded() {
let (wait_chan, wait_port) = pipes::stream(); let (wait_chan, wait_port) = pipes::stream();
let mock_resource_task = do mock_resource_task |response| { let mock_resource_task = do mock_resource_task |response, move wait_port| {
wait_port.recv(); wait_port.recv();
response.send(resource_task::Payload(test_image_bin())); response.send(resource_task::Payload(test_image_bin()));
response.send(resource_task::Done(result::Ok(()))); response.send(resource_task::Done(result::Ok(())));
@ -1031,7 +1031,7 @@ fn should_return_image_on_wait_if_image_is_not_yet_loaded() {
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(copy url));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(WaitForImage(url, response_chan)); image_cache_task.send(WaitForImage(move url, move response_chan));
wait_chan.send(()); wait_chan.send(());
@ -1049,7 +1049,7 @@ fn should_return_image_failed_on_wait_if_image_fails_to_load() {
let (wait_chan, wait_port) = pipes::stream(); let (wait_chan, wait_port) = pipes::stream();
let mock_resource_task = do mock_resource_task |response| { let mock_resource_task = do mock_resource_task |response, move wait_port| {
wait_port.recv(); wait_port.recv();
response.send(resource_task::Payload(test_image_bin())); response.send(resource_task::Payload(test_image_bin()));
response.send(resource_task::Done(result::Err(()))); response.send(resource_task::Done(result::Err(())));
@ -1062,7 +1062,7 @@ fn should_return_image_failed_on_wait_if_image_fails_to_load() {
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(copy url));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(WaitForImage(url, response_chan)); image_cache_task.send(WaitForImage(move url, move response_chan));
wait_chan.send(()); wait_chan.send(());
@ -1089,7 +1089,7 @@ fn sync_cache_should_wait_for_images() {
image_cache_task.send(Decode(copy url)); image_cache_task.send(Decode(copy url));
let (response_chan, response_port) = stream(); let (response_chan, response_port) = stream();
image_cache_task.send(GetImage(url, response_chan)); image_cache_task.send(GetImage(move url, move response_chan));
match response_port.recv() { match response_port.recv() {
ImageReady(_) => (), ImageReady(_) => (),
_ => fail _ => fail

View file

@ -147,11 +147,11 @@ fn should_delegate_to_scheme_loader() {
progress_chan.send(Payload(copy payload)); progress_chan.send(Payload(copy payload));
progress_chan.send(Done(Ok(()))); progress_chan.send(Done(Ok(())));
}; };
let loader_factories = ~[(~"snicklefritz", loader_factory)]; let loader_factories = ~[(~"snicklefritz", move loader_factory)];
let resource_task = create_resource_task_with_loaders(loader_factories); let resource_task = create_resource_task_with_loaders(move loader_factories);
let progress = Port(); let progress = Port();
resource_task.send(Load(url::from_str(~"snicklefritz://heya").get(), progress.chan())); resource_task.send(Load(url::from_str(~"snicklefritz://heya").get(), progress.chan()));
assert progress.recv() == Payload(payload); assert progress.recv() == Payload(move payload);
assert progress.recv() == Done(Ok(())); assert progress.recv() == Done(Ok(()));
resource_task.send(Exit); resource_task.send(Exit);
} }

View file

@ -162,7 +162,7 @@ fn should_get_glyph_advance_stress() {
for iter::repeat(100) { for iter::repeat(100) {
let (chan, port) = pipes::stream(); let (chan, port) = pipes::stream();
ports += [@move port]; ports += [@move port];
do task::spawn { do task::spawn |move chan| {
let lib = FontCache(); let lib = FontCache();
let font = lib.get_test_font(); let font = lib.get_test_font();
let x = font.glyph_h_advance(40u as GlyphIndex); let x = font.glyph_h_advance(40u as GlyphIndex);

View file

@ -186,7 +186,7 @@ mod test {
add_child(&dtree, p, *c); add_child(&dtree, p, *c);
} }
return {p: p, children: children}; return {p: p, children: move children};
} }
#[test] #[test]

View file

@ -48,7 +48,7 @@ mod make_url_tests {
#[test] #[test]
fn should_create_absolute_file_url_if_current_url_is_none_and_str_url_looks_filey() { fn should_create_absolute_file_url_if_current_url_is_none_and_str_url_looks_filey() {
let file = ~"local.html"; let file = ~"local.html";
let url = make_url(file, None); let url = make_url(move file, None);
#debug("url: %?", url); #debug("url: %?", url);
assert url.scheme == ~"file"; assert url.scheme == ~"file";
assert url.path.contains(os::getcwd().to_str()); assert url.path.contains(os::getcwd().to_str());
@ -57,9 +57,9 @@ mod make_url_tests {
#[test] #[test]
fn should_create_url_based_on_old_url_1() { fn should_create_url_based_on_old_url_1() {
let old_str = ~"http://example.com"; let old_str = ~"http://example.com";
let old_url = make_url(old_str, None); let old_url = make_url(move old_str, None);
let new_str = ~"index.html"; let new_str = ~"index.html";
let new_url = make_url(new_str, Some(old_url)); let new_url = make_url(move new_str, Some(move old_url));
assert new_url.scheme == ~"http"; assert new_url.scheme == ~"http";
assert new_url.host == ~"example.com"; assert new_url.host == ~"example.com";
assert new_url.path == ~"/index.html"; assert new_url.path == ~"/index.html";
@ -68,9 +68,9 @@ mod make_url_tests {
#[test] #[test]
fn should_create_url_based_on_old_url_2() { fn should_create_url_based_on_old_url_2() {
let old_str = ~"http://example.com/"; let old_str = ~"http://example.com/";
let old_url = make_url(old_str, None); let old_url = make_url(move old_str, None);
let new_str = ~"index.html"; let new_str = ~"index.html";
let new_url = make_url(new_str, Some(old_url)); let new_url = make_url(move new_str, Some(move old_url));
assert new_url.scheme == ~"http"; assert new_url.scheme == ~"http";
assert new_url.host == ~"example.com"; assert new_url.host == ~"example.com";
assert new_url.path == ~"/index.html"; assert new_url.path == ~"/index.html";
@ -79,9 +79,9 @@ mod make_url_tests {
#[test] #[test]
fn should_create_url_based_on_old_url_3() { fn should_create_url_based_on_old_url_3() {
let old_str = ~"http://example.com/index.html"; let old_str = ~"http://example.com/index.html";
let old_url = make_url(old_str, None); let old_url = make_url(move old_str, None);
let new_str = ~"crumpet.html"; let new_str = ~"crumpet.html";
let new_url = make_url(new_str, Some(old_url)); let new_url = make_url(move new_str, Some(move old_url));
assert new_url.scheme == ~"http"; assert new_url.scheme == ~"http";
assert new_url.host == ~"example.com"; assert new_url.host == ~"example.com";
assert new_url.path == ~"/crumpet.html"; assert new_url.path == ~"/crumpet.html";
@ -90,9 +90,9 @@ mod make_url_tests {
#[test] #[test]
fn should_create_url_based_on_old_url_4() { fn should_create_url_based_on_old_url_4() {
let old_str = ~"http://example.com/snarf/index.html"; let old_str = ~"http://example.com/snarf/index.html";
let old_url = make_url(old_str, None); let old_url = make_url(move old_str, None);
let new_str = ~"crumpet.html"; let new_str = ~"crumpet.html";
let new_url = make_url(new_str, Some(old_url)); let new_url = make_url(move new_str, Some(move old_url));
assert new_url.scheme == ~"http"; assert new_url.scheme == ~"http";
assert new_url.host == ~"example.com"; assert new_url.host == ~"example.com";
assert new_url.path == ~"/snarf/crumpet.html"; assert new_url.path == ~"/snarf/crumpet.html";