test: Fix tests.
This commit is contained in:
parent
f30f54e9d0
commit
876483dcf4
31 changed files with 114 additions and 190 deletions
|
|
@ -225,7 +225,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
}
|
||||
|
||||
/// A parallel version of the bfs function.
|
||||
fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
||||
fn pbfs(graph: &arc::ARC<graph>, key: node_id) -> bfs_result {
|
||||
// This works by doing functional updates of a color vector.
|
||||
|
||||
enum color {
|
||||
|
|
@ -236,7 +236,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
|||
black(node_id)
|
||||
};
|
||||
|
||||
let graph_vec = arc::get(&graph); // FIXME #3387 requires this temp
|
||||
let graph_vec = arc::get(graph); // FIXME #3387 requires this temp
|
||||
let mut colors = do vec::from_fn(graph_vec.len()) |i| {
|
||||
if i as node_id == key {
|
||||
gray(key)
|
||||
|
|
@ -271,7 +271,7 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result {
|
|||
let color_vec = arc::get(&color); // FIXME #3387 requires this temp
|
||||
colors = do par::mapi(*color_vec) {
|
||||
let colors = arc::clone(&color);
|
||||
let graph = arc::clone(&graph);
|
||||
let graph = arc::clone(graph);
|
||||
let result: ~fn(+x: uint, +y: &color) -> color = |i, c| {
|
||||
let colors = arc::get(&colors);
|
||||
let graph = arc::get(&graph);
|
||||
|
|
@ -496,7 +496,7 @@ fn main() {
|
|||
}
|
||||
|
||||
let start = time::precise_time_s();
|
||||
let bfs_tree = pbfs(graph_arc, *root);
|
||||
let bfs_tree = pbfs(&graph_arc, *root);
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
total_par += stop - start;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ enum request {
|
|||
stop
|
||||
}
|
||||
|
||||
fn server(requests: Port<request>, responses: comm::Chan<uint>) {
|
||||
fn server(requests: &Port<request>, responses: &comm::Chan<uint>) {
|
||||
let mut count = 0u;
|
||||
let mut done = false;
|
||||
while !done {
|
||||
|
|
@ -76,7 +76,7 @@ fn run(args: &[~str]) {
|
|||
};
|
||||
}
|
||||
do task::spawn || {
|
||||
server(from_parent, to_parent);
|
||||
server(&from_parent, &to_parent);
|
||||
}
|
||||
|
||||
for vec::each(worker_results) |r| {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ enum request {
|
|||
stop
|
||||
}
|
||||
|
||||
fn server(requests: PortSet<request>, responses: Chan<uint>) {
|
||||
fn server(requests: &PortSet<request>, responses: &Chan<uint>) {
|
||||
let mut count = 0;
|
||||
let mut done = false;
|
||||
while !done {
|
||||
|
|
@ -73,7 +73,7 @@ fn run(args: &[~str]) {
|
|||
};
|
||||
}
|
||||
do task::spawn || {
|
||||
server(from_parent, to_parent);
|
||||
server(&from_parent, &to_parent);
|
||||
}
|
||||
|
||||
for vec::each(worker_results) |r| {
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ fn windows_with_carry(bb: &[u8], nn: uint,
|
|||
}
|
||||
|
||||
fn make_sequence_processor(sz: uint,
|
||||
from_parent: comm::Port<~[u8]>,
|
||||
to_parent: comm::Chan<~str>) {
|
||||
from_parent: &comm::Port<~[u8]>,
|
||||
to_parent: &comm::Chan<~str>) {
|
||||
let mut freqs: HashMap<~[u8], uint> = HashMap::new();
|
||||
let mut carry: ~[u8] = ~[];
|
||||
let mut total: uint = 0u;
|
||||
|
|
@ -140,7 +140,7 @@ fn make_sequence_processor(sz: uint,
|
|||
// given a FASTA file on stdin, process sequence THREE
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
|
||||
let rdr = if os::getenv(~"RUST_BENCH").is_some() {
|
||||
// FIXME: Using this compile-time env variable is a crummy way to
|
||||
// get to this massive data set, but include_bin! chokes on it (#2598)
|
||||
let path = Path(env!("CFG_SRC_DIR"))
|
||||
|
|
@ -168,7 +168,7 @@ fn main() {
|
|||
let (from_parent, to_child) = comm::stream();
|
||||
|
||||
do task::spawn_with(from_parent) |from_parent| {
|
||||
make_sequence_processor(sz, from_parent, to_parent_);
|
||||
make_sequence_processor(sz, &from_parent, &to_parent_);
|
||||
};
|
||||
|
||||
to_child
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use core::result;
|
|||
use core::result::{Ok, Err};
|
||||
|
||||
fn fib(n: int) -> int {
|
||||
fn pfib(c: Chan<int>, n: int) {
|
||||
fn pfib(c: &Chan<int>, n: int) {
|
||||
if n == 0 {
|
||||
c.send(0);
|
||||
} else if n <= 2 {
|
||||
|
|
@ -38,15 +38,15 @@ fn fib(n: int) -> int {
|
|||
} else {
|
||||
let p = PortSet::new();
|
||||
let ch = p.chan();
|
||||
task::spawn(|| pfib(ch, n - 1) );
|
||||
task::spawn(|| pfib(&ch, n - 1) );
|
||||
let ch = p.chan();
|
||||
task::spawn(|| pfib(ch, n - 2) );
|
||||
task::spawn(|| pfib(&ch, n - 2) );
|
||||
c.send(p.recv() + p.recv());
|
||||
}
|
||||
}
|
||||
|
||||
let (p, ch) = stream();
|
||||
let _t = task::spawn(|| pfib(ch, n) );
|
||||
let _t = task::spawn(|| pfib(&ch, n) );
|
||||
p.recv()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
fn f(&&_x: int) {}
|
||||
fn g(_a: &fn(+v: int)) {}
|
||||
fn main() { g(f); }
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn take(_x: ~int) { }
|
||||
|
||||
fn from_by_ref_arg(&&x: ~int) {
|
||||
take(x); //~ ERROR illegal move from argument `x`, which is not copy or move mode
|
||||
}
|
||||
|
||||
fn from_copy_arg(+x: ~int) {
|
||||
take(x);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// In this test, the mode gets inferred to ++ due to the apply_int(),
|
||||
// but then we get a failure in the generic apply().
|
||||
|
||||
fn apply<A>(f: &fn(A) -> A, a: A) -> A { f(a) }
|
||||
fn apply_int(f: &fn(int) -> int, a: int) -> int { f(a) }
|
||||
|
||||
fn main() {
|
||||
let f = {|i| i};
|
||||
assert!(apply_int(f, 2) == 2);
|
||||
assert!(apply(f, 2) == 2); //~ ERROR expected argument mode &&
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Note: it would be nice to give fewer warnings in these cases.
|
||||
|
||||
fn mutate_by_mut_ref(x: &mut uint) {
|
||||
*x = 0;
|
||||
}
|
||||
|
||||
fn mutate_by_ref(&&x: uint) {
|
||||
//~^ WARNING unused variable: `x`
|
||||
x = 0; //~ ERROR assigning to argument
|
||||
}
|
||||
|
||||
fn mutate_by_copy(+x: uint) {
|
||||
//~^ WARNING unused variable: `x`
|
||||
x = 0; //~ ERROR assigning to argument
|
||||
//~^ WARNING value assigned to `x` is never read
|
||||
}
|
||||
|
||||
fn mutate_by_move(+x: uint) {
|
||||
//~^ WARNING unused variable: `x`
|
||||
x = 0; //~ ERROR assigning to argument
|
||||
//~^ WARNING value assigned to `x` is never read
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ fn foo(s: @int) {
|
|||
_ => { debug!("?"); fail!(); }
|
||||
}
|
||||
debug!(::core::sys::refcount(s));
|
||||
assert!((::core::sys::refcount(s) == count + 1u));
|
||||
assert_eq!(::core::sys::refcount(s), count + 1u);
|
||||
let _ = ::core::sys::refcount(s); // don't get bitten by last-use.
|
||||
}
|
||||
|
||||
|
|
@ -39,5 +39,5 @@ pub fn main() {
|
|||
debug!("%u", ::core::sys::refcount(s));
|
||||
let count2 = ::core::sys::refcount(s);
|
||||
let _ = ::core::sys::refcount(s); // don't get bitten by last-use.
|
||||
assert!(count == count2);
|
||||
assert_eq!(count, count2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ pub fn main() {
|
|||
//let bt0 = sys::rusti::frame_address(1u32);
|
||||
//debug!("%?", bt0);
|
||||
do cci_iter_lib::iter(~[1, 2, 3]) |i| {
|
||||
io::print(fmt!("%d", i));
|
||||
io::print(fmt!("%d", *i));
|
||||
//assert!(bt0 == sys::rusti::frame_address(2u32));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ use cci_nested_lib::*;
|
|||
|
||||
pub fn main() {
|
||||
let lst = new_int_alist();
|
||||
alist_add(lst, 22, ~"hi");
|
||||
alist_add(lst, 44, ~"ho");
|
||||
assert!(alist_get(lst, 22) == ~"hi");
|
||||
assert!(alist_get(lst, 44) == ~"ho");
|
||||
alist_add(&lst, 22, ~"hi");
|
||||
alist_add(&lst, 44, ~"ho");
|
||||
assert!(alist_get(&lst, 22) == ~"hi");
|
||||
assert!(alist_get(&lst, 44) == ~"ho");
|
||||
|
||||
let lst = new_int_alist_2();
|
||||
alist_add(lst, 22, ~"hi");
|
||||
alist_add(lst, 44, ~"ho");
|
||||
assert!(alist_get(lst, 22) == ~"hi");
|
||||
assert!(alist_get(lst, 44) == ~"ho");
|
||||
alist_add(&lst, 22, ~"hi");
|
||||
alist_add(&lst, 44, ~"ho");
|
||||
assert!(alist_get(&lst, 22) == ~"hi");
|
||||
assert!(alist_get(&lst, 44) == ~"ho");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,5 +68,4 @@ pub fn main() {
|
|||
for uint::range(1u, 10u) |_i| {
|
||||
make_speak(copy nyan);
|
||||
}
|
||||
assert!((nyan.eat()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ fn addr_of<T>(ptr: &T) -> uint {
|
|||
}
|
||||
|
||||
fn is_aligned<T>(ptr: &T) -> bool {
|
||||
(ptr::to_unsafe_ptr(ptr) % sys::min_align_of::<T>()) == 0
|
||||
unsafe {
|
||||
let addr: uint = ::cast::transmute(ptr);
|
||||
(addr % sys::min_align_of::<T>()) == 0
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ struct Ccx {
|
|||
fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> {
|
||||
unsafe {
|
||||
cast::transmute(libc::malloc(sys::size_of::<Bcx<'blk>>()
|
||||
as libc::size_t));
|
||||
as libc::size_t))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::cell::Cell;
|
||||
|
||||
pub fn main() { test05(); }
|
||||
|
||||
fn test05_start(&&f: ~fn(int)) {
|
||||
|
|
@ -20,7 +22,8 @@ fn test05() {
|
|||
error!(*three + n); // will copy x into the closure
|
||||
assert!((*three == 3));
|
||||
};
|
||||
let fn_to_send = Cell(fn_to_send);
|
||||
task::spawn(|| {
|
||||
test05_start(fn_to_send);
|
||||
test05_start(fn_to_send.take());
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ fn build<A, B: buildable<A>>(builder: &fn(push: &fn(+v: A))) -> B {
|
|||
|
||||
/// Apply a function to each element of an iterable and return the results
|
||||
fn map<T, IT: BaseIter<T>, U, BU: buildable<U>>
|
||||
(v: IT, f: &fn(T) -> U) -> BU {
|
||||
(v: IT, f: &fn(&T) -> U) -> BU {
|
||||
do build |push| {
|
||||
for v.each() |elem| {
|
||||
push(f(*elem));
|
||||
push(f(elem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,9 +78,9 @@ pub fn main() {
|
|||
let v: @[int] = seq_range(0, 10);
|
||||
assert!(v == @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
||||
|
||||
let v: @[int] = map(&[1,2,3], |x| 1+x);
|
||||
let v: @[int] = map(&[1,2,3], |&x| 1+x);
|
||||
assert!(v == @[2, 3, 4]);
|
||||
let v: ~[int] = map(&[1,2,3], |x| 1+x);
|
||||
let v: ~[int] = map(&[1,2,3], |&x| 1+x);
|
||||
assert!(v == ~[2, 3, 4]);
|
||||
|
||||
assert!(bool_like::select(true, 9, 14) == 9);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use core::comm::Port;
|
|||
|
||||
pub fn main() { test05(); }
|
||||
|
||||
fn test05_start(ch : Chan<int>) {
|
||||
fn test05_start(ch : &Chan<int>) {
|
||||
ch.send(10);
|
||||
error!("sent 10");
|
||||
ch.send(20);
|
||||
|
|
@ -28,8 +28,8 @@ fn test05_start(ch : Chan<int>) {
|
|||
|
||||
fn test05() {
|
||||
let (po, ch) = comm::stream();
|
||||
task::spawn(|| test05_start(ch) );
|
||||
let mut value = po.recv();
|
||||
task::spawn(|| test05_start(&ch) );
|
||||
let mut value: int = po.recv();
|
||||
error!(value);
|
||||
value = po.recv();
|
||||
error!(value);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
extern mod std;
|
||||
|
||||
fn start(c: comm::Chan<int>, start: int, number_of_messages: int) {
|
||||
fn start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
|
||||
let mut i: int = 0;
|
||||
while i < number_of_messages { c.send(start + i); i += 1; }
|
||||
}
|
||||
|
|
@ -20,6 +20,6 @@ fn start(c: comm::Chan<int>, start: int, number_of_messages: int) {
|
|||
pub fn main() {
|
||||
debug!("Check that we don't deadlock.");
|
||||
let (p, ch) = comm::stream();
|
||||
task::try(|| start(ch, 0, 10) );
|
||||
task::try(|| start(&ch, 0, 10) );
|
||||
debug!("Joined task");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ extern mod std;
|
|||
|
||||
pub fn main() { test00(); }
|
||||
|
||||
fn test00_start(c: comm::Chan<int>, start: int, number_of_messages: int) {
|
||||
fn test00_start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
|
||||
let mut i: int = 0;
|
||||
while i < number_of_messages { c.send(start + i); i += 1; }
|
||||
}
|
||||
|
|
@ -27,19 +27,19 @@ fn test00() {
|
|||
|
||||
let c = p.chan();
|
||||
do task::spawn || {
|
||||
test00_start(c, number_of_messages * 0, number_of_messages);
|
||||
test00_start(&c, number_of_messages * 0, number_of_messages);
|
||||
}
|
||||
let c = p.chan();
|
||||
do task::spawn || {
|
||||
test00_start(c, number_of_messages * 1, number_of_messages);
|
||||
test00_start(&c, number_of_messages * 1, number_of_messages);
|
||||
}
|
||||
let c = p.chan();
|
||||
do task::spawn || {
|
||||
test00_start(c, number_of_messages * 2, number_of_messages);
|
||||
test00_start(&c, number_of_messages * 2, number_of_messages);
|
||||
}
|
||||
let c = p.chan();
|
||||
do task::spawn || {
|
||||
test00_start(c, number_of_messages * 3, number_of_messages);
|
||||
test00_start(&c, number_of_messages * 3, number_of_messages);
|
||||
}
|
||||
|
||||
let mut i: int = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue