test: De-~mut the test suite. rs=demuting
This commit is contained in:
parent
e2f90091cf
commit
e3d43e490b
@ -87,17 +87,12 @@ fn main() {
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
//error!("spawning %?", i);
|
||||
let (new_chan, num_port) = init();
|
||||
let num_chan2 = ~mut None;
|
||||
*num_chan2 <-> num_chan;
|
||||
let num_port = ~mut Some(num_port);
|
||||
let new_future = do future::spawn() || {
|
||||
let mut num_chan = None;
|
||||
num_chan <-> *num_chan2;
|
||||
let mut num_port1 = None;
|
||||
num_port1 <-> *num_port;
|
||||
thread_ring(i, msg_per_task,
|
||||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
let num_chan2 = Cell(num_chan);
|
||||
let num_port = Cell(num_port);
|
||||
let new_future = do future::spawn() {
|
||||
let num_chan = num_chan2.take();
|
||||
let num_port1 = num_port.take();
|
||||
thread_ring(i, msg_per_task, num_chan, num_port1)
|
||||
};
|
||||
futures.push(new_future);
|
||||
num_chan = Some(new_chan);
|
||||
|
@ -17,11 +17,12 @@
|
||||
// This version uses automatically compiled channel contracts.
|
||||
|
||||
extern mod std;
|
||||
|
||||
use core::cell::Cell;
|
||||
use core::pipes::recv;
|
||||
use std::time;
|
||||
use std::future;
|
||||
|
||||
use core::pipes::recv;
|
||||
|
||||
proto! ring (
|
||||
num:send {
|
||||
num(uint) -> num
|
||||
@ -80,17 +81,12 @@ fn main() {
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
//error!("spawning %?", i);
|
||||
let (new_chan, num_port) = ring::init();
|
||||
let num_chan2 = ~mut None;
|
||||
*num_chan2 <-> num_chan;
|
||||
let num_port = ~mut Some(num_port);
|
||||
let num_chan2 = Cell(num_chan);
|
||||
let num_port = Cell(num_port);
|
||||
let new_future = do future::spawn || {
|
||||
let mut num_chan = None;
|
||||
num_chan <-> *num_chan2;
|
||||
let mut num_port1 = None;
|
||||
num_port1 <-> *num_port;
|
||||
thread_ring(i, msg_per_task,
|
||||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
let num_chan = num_chan2.take();
|
||||
let num_port1 = num_port.take();
|
||||
thread_ring(i, msg_per_task, num_chan, num_port1)
|
||||
};
|
||||
futures.push(new_future);
|
||||
num_chan = Some(new_chan);
|
||||
|
@ -87,17 +87,12 @@ fn main() {
|
||||
for uint::range(1u, num_tasks) |i| {
|
||||
//error!("spawning %?", i);
|
||||
let (new_chan, num_port) = init();
|
||||
let num_chan2 = ~mut None;
|
||||
*num_chan2 <-> num_chan;
|
||||
let num_port = ~mut Some(num_port);
|
||||
let new_future = do future::spawn || {
|
||||
let mut num_chan = None;
|
||||
num_chan <-> *num_chan2;
|
||||
let mut num_port1 = None;
|
||||
num_port1 <-> *num_port;
|
||||
thread_ring(i, msg_per_task,
|
||||
option::unwrap(num_chan),
|
||||
option::unwrap(num_port1))
|
||||
let num_chan2 = Cell(num_chan);
|
||||
let num_port = Cell(num_port);
|
||||
let new_future = do future::spawn {
|
||||
let num_chan = num_chan2.take();
|
||||
let num_port1 = num_port.take();
|
||||
thread_ring(i, msg_per_task, num_chan, num_port1)
|
||||
};
|
||||
futures.push(new_future);
|
||||
num_chan = Some(new_chan);
|
||||
|
@ -17,13 +17,15 @@
|
||||
//
|
||||
// The filename is a song reference; google it in quotes.
|
||||
|
||||
use core::cell::Cell;
|
||||
|
||||
fn child_generation(gens_left: uint, -c: comm::Chan<()>) {
|
||||
// This used to be O(n^2) in the number of generations that ever existed.
|
||||
// With this code, only as many generations are alive at a time as tasks
|
||||
// alive at a time,
|
||||
let c = ~mut Some(c);
|
||||
do task::spawn_supervised || {
|
||||
let c = option::swap_unwrap(c);
|
||||
let c = Cell(c);
|
||||
do task::spawn_supervised {
|
||||
let c = c.take();
|
||||
if gens_left & 1 == 1 {
|
||||
task::yield(); // shake things up a bit
|
||||
}
|
||||
|
@ -11,9 +11,9 @@
|
||||
// error-pattern: mismatched types
|
||||
|
||||
fn main() {
|
||||
let v = ~[mut @mut ~mut ~[0]];
|
||||
let v = @[mut @mut @mut @[0]];
|
||||
|
||||
fn f(&&v: ~[mut @mut ~mut ~[const int]]) {
|
||||
fn f(&&v: @[mut @mut @mut @[const int]]) {
|
||||
}
|
||||
|
||||
f(v);
|
||||
|
@ -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.
|
||||
|
||||
// error-pattern: mismatched types
|
||||
|
||||
fn main() {
|
||||
let v = ~mut ~[0];
|
||||
|
||||
fn f(&&v: ~mut ~[const int]) {
|
||||
*v = ~[mut 3]
|
||||
}
|
||||
|
||||
f(v);
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use core::cell::Cell;
|
||||
|
||||
struct Port<T>(@T);
|
||||
|
||||
fn main() {
|
||||
@ -25,11 +27,10 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let x = ~mut Some(foo(Port(@())));
|
||||
let x = Cell(foo(Port(@())));
|
||||
|
||||
do task::spawn {
|
||||
let mut y = None;
|
||||
*x <-> y; //~ ERROR value has non-owned type
|
||||
let y = x.take(); //~ ERROR value has non-owned type
|
||||
log(error, y);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +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 main() {
|
||||
let i: ~int = ~mut 0;
|
||||
}
|
@ -20,7 +20,7 @@ fn borrow(x: &int, f: fn(x: &int)) {
|
||||
struct F { f: ~int }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = ~mut @F{f: ~3};
|
||||
let mut x = ~@F{f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert *b_x == 3;
|
||||
assert ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x));
|
||||
|
@ -21,9 +21,6 @@ impl Box {
|
||||
fn set_many2(@mut self, xs: &[uint]) {
|
||||
for xs.each |x| { self.x = *x; }
|
||||
}
|
||||
fn set_many3(~mut self, xs: &[uint]) {
|
||||
for xs.each |x| { self.x = *x; }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -29,7 +29,7 @@ extern mod rusti {
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let x = ~mut 1;
|
||||
let mut x = ~1;
|
||||
|
||||
assert rusti::atomic_cxchg(x, 1, 2) == 1;
|
||||
assert *x == 2;
|
||||
|
@ -318,18 +318,16 @@ pub fn main() {
|
||||
// Commented out because of option::get error
|
||||
|
||||
let (client_, server_) = pingpong::init();
|
||||
let client_ = ~mut Some(client_);
|
||||
let server_ = ~mut Some(server_);
|
||||
let client_ = Cell(client_);
|
||||
let server_ = Cell(server_);
|
||||
|
||||
task::spawn {|client_|
|
||||
let mut client__ = none;
|
||||
*client_ <-> client__;
|
||||
client(option::unwrap(client__));
|
||||
let client__ = client_.take();
|
||||
client(client__);
|
||||
};
|
||||
task::spawn {|server_|
|
||||
let mut server_ˊ = none;
|
||||
*server_ <-> server_ˊ;
|
||||
server(option::unwrap(server_ˊ));
|
||||
let server__ = server_.take();
|
||||
server(server_ˊ);
|
||||
};
|
||||
*/
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
// experiment with what code the compiler should generate for bounded
|
||||
// protocols.
|
||||
|
||||
use core::cell::Cell;
|
||||
|
||||
// This was generated initially by the pipe compiler, but it's been
|
||||
// modified in hopefully straightforward ways.
|
||||
@ -111,16 +112,14 @@ mod test {
|
||||
|
||||
pub fn main() {
|
||||
let (client_, server_) = ::pingpong::init();
|
||||
let client_ = ~mut Some(client_);
|
||||
let server_ = ~mut Some(server_);
|
||||
do task::spawn || {
|
||||
let mut client__ = None;
|
||||
*client_ <-> client__;
|
||||
test::client(option::unwrap(client__));
|
||||
let client_ = Cell(client_);
|
||||
let server_ = Cell(server_);
|
||||
do task::spawn {
|
||||
let client__ = client_.take();
|
||||
test::client(client__);
|
||||
};
|
||||
do task::spawn || {
|
||||
let mut server_ˊ = None;
|
||||
*server_ <-> server_ˊ;
|
||||
test::server(option::unwrap(server_ˊ));
|
||||
do task::spawn {
|
||||
let server__ = server_.take();
|
||||
test::server(server__);
|
||||
};
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
// An example to make sure the protocol parsing syntax extension works.
|
||||
|
||||
use core::cell::Cell;
|
||||
use core::option;
|
||||
|
||||
proto! pingpong (
|
||||
@ -49,17 +50,15 @@ mod test {
|
||||
|
||||
pub fn main() {
|
||||
let (client_, server_) = pingpong::init();
|
||||
let client_ = ~mut Some(client_);
|
||||
let server_ = ~mut Some(server_);
|
||||
let client_ = Cell(client_);
|
||||
let server_ = Cell(server_);
|
||||
|
||||
do task::spawn || {
|
||||
let mut client__ = None;
|
||||
*client_ <-> client__;
|
||||
test::client(option::unwrap(client__));
|
||||
do task::spawn {
|
||||
let client__ = client_.take();
|
||||
test::client(client__);
|
||||
};
|
||||
do task::spawn || {
|
||||
let mut server_ˊ = None;
|
||||
*server_ <-> server_ˊ;
|
||||
test::server(option::unwrap(server_ˊ));
|
||||
do task::spawn {
|
||||
let server__ = server_.take();
|
||||
test::server(server__);
|
||||
};
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ pure fn sums_to(v: ~[int], sum: int) -> bool {
|
||||
}
|
||||
|
||||
pure fn sums_to_using_uniq(v: ~[int], sum: int) -> bool {
|
||||
let mut i = 0u, sum0 = ~mut 0;
|
||||
let mut i = 0u, sum0 = ~0;
|
||||
while i < v.len() {
|
||||
*sum0 += v[i];
|
||||
i += 1u;
|
||||
@ -40,7 +40,7 @@ pure fn sums_to_using_rec(v: ~[int], sum: int) -> bool {
|
||||
struct F<T> { f: T }
|
||||
|
||||
pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool {
|
||||
let mut i = 0u, sum0 = F {f: ~mut 0};
|
||||
let mut i = 0u, sum0 = F {f: ~0};
|
||||
while i < v.len() {
|
||||
*sum0.f += v[i];
|
||||
i += 1u;
|
||||
|
@ -31,7 +31,7 @@ pub fn main() {
|
||||
debug!("y=%d", y);
|
||||
assert y == 6;
|
||||
|
||||
let x = ~mut 6;
|
||||
let mut x = ~6;
|
||||
let y = x.get();
|
||||
debug!("y=%d", y);
|
||||
assert y == 6;
|
||||
|
@ -13,6 +13,7 @@
|
||||
// A port of task-killjoin to use a class with a dtor to manage
|
||||
// the join.
|
||||
|
||||
use core::cell::Cell;
|
||||
use core::comm::*;
|
||||
|
||||
struct notify {
|
||||
@ -49,11 +50,9 @@ fn joinable(f: fn~()) -> Port<bool> {
|
||||
*b = true;
|
||||
}
|
||||
let (p, c) = stream();
|
||||
let c = ~mut Some(c);
|
||||
let c = Cell(c);
|
||||
do task::spawn_unlinked {
|
||||
let mut cc = None;
|
||||
*c <-> cc;
|
||||
let ccc = option::unwrap(cc);
|
||||
let ccc = c.take();
|
||||
wrapper(ccc, f)
|
||||
}
|
||||
p
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
let i = ~mut 1;
|
||||
let mut i = ~1;
|
||||
// Should be a copy
|
||||
let mut j;
|
||||
j = copy i;
|
||||
|
@ -9,9 +9,9 @@
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
let i = ~mut 1;
|
||||
let mut i = ~1;
|
||||
// Should be a copy
|
||||
let j = copy i;
|
||||
let mut j = copy i;
|
||||
*i = 2;
|
||||
*j = 3;
|
||||
assert *i == 2;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
let a = ~[~mut 10];
|
||||
let mut a = ~[~10];
|
||||
let b = copy a;
|
||||
|
||||
assert *a[0] == 10;
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
let i = ~mut 0;
|
||||
let mut i = ~0;
|
||||
*i = 1;
|
||||
assert *i == 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user