test: Fix a bunch of test cases. rs=burning
This commit is contained in:
parent
b8cfd5c414
commit
3440482d8d
16 changed files with 33 additions and 27 deletions
|
@ -1123,7 +1123,7 @@ mod tests {
|
|||
log(debug, tmpfile);
|
||||
let frood: ~str =
|
||||
~"A hoopy frood who really knows where his towel is.";
|
||||
log(debug, frood);
|
||||
log(debug, copy frood);
|
||||
{
|
||||
let out: io::Writer =
|
||||
result::get(
|
||||
|
@ -1132,7 +1132,7 @@ mod tests {
|
|||
}
|
||||
let inp: io::Reader = result::get(&io::file_reader(tmpfile));
|
||||
let frood2: ~str = inp.read_c_str();
|
||||
log(debug, frood2);
|
||||
log(debug, copy frood2);
|
||||
assert frood == frood2;
|
||||
}
|
||||
|
||||
|
|
|
@ -946,7 +946,7 @@ mod tests {
|
|||
while i < 100 { s += ~"aaaaaaaaaa"; i += 1; }
|
||||
let n = make_rand_name();
|
||||
setenv(n, s);
|
||||
log(debug, s);
|
||||
log(debug, copy s);
|
||||
assert getenv(n) == option::Some(move s);
|
||||
}
|
||||
|
||||
|
@ -955,7 +955,7 @@ mod tests {
|
|||
let path = os::self_exe_path();
|
||||
assert path.is_some();
|
||||
let path = path.get();
|
||||
log(debug, path);
|
||||
log(debug, copy path);
|
||||
|
||||
// Hard to test this function
|
||||
assert path.is_absolute;
|
||||
|
|
|
@ -440,8 +440,8 @@ mod tests {
|
|||
readclose(pipe_err.in);
|
||||
os::waitpid(pid);
|
||||
|
||||
log(debug, expected);
|
||||
log(debug, actual);
|
||||
log(debug, copy expected);
|
||||
log(debug, copy actual);
|
||||
assert (expected == actual);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn main() {
|
||||
let x = ~{mut a: ~10, b: ~20};
|
||||
match x {
|
||||
~{a, b} => { assert *a == 10; (*x).a = ~30; assert *a == 30; }
|
||||
~{ref a, ref b} => { assert **a == 10; (*x).a = ~30; assert **a == 30; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ fn iter_vec<T>(v: ~[T], f: fn(T)) { for v.each |x| { f(*x); } }
|
|||
fn main() {
|
||||
let v = ~[1, 2, 3, 4, 5];
|
||||
let mut sum = 0;
|
||||
iter_vec(v, |i| {
|
||||
iter_vec(v, |j| {
|
||||
iter_vec(copy v, |i| {
|
||||
iter_vec(copy v, |j| {
|
||||
log(error, i * j);
|
||||
sum += i * j;
|
||||
});
|
||||
|
|
|
@ -5,6 +5,6 @@ fn main() {
|
|||
vec::map2(~[1, 2, 3, 4, 5],
|
||||
~[true, false, false, true, true],
|
||||
|i, b| if *b { -(*i) } else { *i } );
|
||||
log(error, v);
|
||||
log(error, copy v);
|
||||
assert (v == ~[-1, 2, 3, -4, -5]);
|
||||
}
|
||||
|
|
|
@ -76,8 +76,8 @@ fn annoy_neighbors<T: noisy>(critter: T) {
|
|||
fn main() {
|
||||
let nyan : cat = cat(0u, 2, ~"nyan");
|
||||
let whitefang : dog = dog();
|
||||
annoy_neighbors(nyan as noisy);
|
||||
annoy_neighbors(whitefang as noisy);
|
||||
annoy_neighbors((copy nyan) as noisy);
|
||||
annoy_neighbors((copy whitefang) as noisy);
|
||||
assert(nyan.meow_count() == 10u);
|
||||
assert(*whitefang.volume == 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat {
|
|||
cat {
|
||||
meows: in_x,
|
||||
how_hungry: in_y,
|
||||
name: in_name
|
||||
name: copy in_name
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ fn main() {
|
|||
assert x.quux() == 10;
|
||||
|
||||
let y = ~thing({mut a: @10});
|
||||
assert y.bar() == 10;
|
||||
assert (copy y).bar() == 10;
|
||||
assert y.quux() == 10;
|
||||
|
||||
let z = thing({mut a: @11});
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
type compare<T> = fn@(~T, ~T) -> bool;
|
||||
|
||||
fn test_generic<T: Copy>(expected: ~T, eq: compare<T>) {
|
||||
let actual: ~T = match true { true => { expected }, _ => fail ~"wat" };
|
||||
let actual: ~T = match true {
|
||||
true => { copy expected },
|
||||
_ => fail ~"wat"
|
||||
};
|
||||
assert (eq(expected, actual));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
type compare<T> = fn@(T, T) -> bool;
|
||||
|
||||
fn test_generic<T: Copy>(expected: T, eq: compare<T>) {
|
||||
let actual: T = match true { true => expected, _ => fail ~"wat" };
|
||||
let actual: T = match true {
|
||||
true => copy expected,
|
||||
_ => fail ~"wat"
|
||||
};
|
||||
assert (eq(expected, actual));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
type compare<T> = fn@(~T, ~T) -> bool;
|
||||
|
||||
fn test_generic<T: Copy>(expected: ~T, eq: compare<T>) {
|
||||
let actual: ~T = { expected };
|
||||
let actual: ~T = { copy expected };
|
||||
assert (eq(expected, actual));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ fn id<T: Copy Send>(t: T) -> T { return t; }
|
|||
|
||||
fn main() {
|
||||
let expected = ~100;
|
||||
let actual = id::<~int>(expected);
|
||||
let actual = id::<~int>(copy expected);
|
||||
log(debug, *actual);
|
||||
assert (*expected == *actual);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ mod map_reduce {
|
|||
fn emit(im: map::HashMap<~str, int>, ctrl: Chan<ctrl_proto>, key: ~str,
|
||||
val: ~str) {
|
||||
let mut c;
|
||||
match im.find(key) {
|
||||
match im.find(copy key) {
|
||||
Some(_c) => { c = _c }
|
||||
None => {
|
||||
let p = Port();
|
||||
|
@ -70,7 +70,7 @@ mod map_reduce {
|
|||
|
||||
reducers = map::HashMap();
|
||||
|
||||
start_mappers(Chan(&ctrl), inputs);
|
||||
start_mappers(Chan(&ctrl), copy inputs);
|
||||
|
||||
let mut num_mappers = vec::len(inputs) as int;
|
||||
|
||||
|
|
|
@ -207,8 +207,8 @@ mod pingpong {
|
|||
enum pong = pipes::send_packet<ping>;
|
||||
|
||||
fn liberate_ping(-p: ping) -> pipes::send_packet<pong> unsafe {
|
||||
let addr : *pipes::send_packet<pong> = match p {
|
||||
ping(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
let addr : *pipes::send_packet<pong> = match &p {
|
||||
&ping(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value = move *addr;
|
||||
cast::forget(move p);
|
||||
|
@ -216,8 +216,8 @@ mod pingpong {
|
|||
}
|
||||
|
||||
fn liberate_pong(-p: pong) -> pipes::send_packet<ping> unsafe {
|
||||
let addr : *pipes::send_packet<ping> = match p {
|
||||
pong(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
let addr : *pipes::send_packet<ping> = match &p {
|
||||
&pong(x) => { cast::transmute(ptr::addr_of(&x)) }
|
||||
};
|
||||
let liberated_value = move *addr;
|
||||
cast::forget(move p);
|
||||
|
|
|
@ -31,9 +31,9 @@ fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str
|
|||
|
||||
fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str, object)
|
||||
{
|
||||
match data
|
||||
match &data
|
||||
{
|
||||
std::json::Object(interface) =>
|
||||
&std::json::Object(interface) =>
|
||||
{
|
||||
let name = lookup(interface, ~"ifDescr", ~"");
|
||||
let label = fmt!("%s-%s", managed_ip, name);
|
||||
|
|
Loading…
Add table
Reference in a new issue