test: Remove non-procedure uses of do from compiletest, libstd tests,

compile-fail tests, run-fail tests, and run-pass tests.
This commit is contained in:
Patrick Walton 2013-11-21 17:23:21 -08:00
parent 8ceb374ab7
commit f571e46ddb
128 changed files with 579 additions and 641 deletions

View File

@ -266,12 +266,12 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
let file = file.clone();
debug!("inspecting file {}", file.display());
if is_test(config, &file) {
let t = do make_test(config, &file) {
let t = make_test(config, &file, || {
match config.mode {
mode_codegen => make_metrics_test_closure(config, &file),
_ => make_test_closure(config, &file)
}
};
});
tests.push(t)
}
}

View File

@ -39,7 +39,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
let mut pp_exact = None;
let mut debugger_cmds = ~[];
let mut check_lines = ~[];
do iter_header(testfile) |ln| {
iter_header(testfile, |ln| {
match parse_error_pattern(ln) {
Some(ep) => error_patterns.push(ep),
None => ()
@ -74,7 +74,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
};
true
};
});
return TestProps {
error_patterns: error_patterns,
compile_flags: compile_flags,
@ -91,13 +91,13 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
~"xfail-" + util::get_os(config.target)
}
let val = do iter_header(testfile) |ln| {
let val = iter_header(testfile, |ln| {
if parse_name_directive(ln, "xfail-test") { false }
else if parse_name_directive(ln, xfail_target(config)) { false }
else if config.mode == common::mode_pretty &&
parse_name_directive(ln, "xfail-pretty") { false }
else { true }
};
});
!val
}
@ -143,7 +143,7 @@ fn parse_check_line(line: &str) -> Option<~str> {
}
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
do parse_name_value_directive(line, ~"exec-env").map |nv| {
parse_name_value_directive(line, ~"exec-env").map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
@ -155,7 +155,7 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
}
n => fail!("Expected 1 or 2 strings, not {}", n)
}
}
})
}
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {

View File

@ -22,11 +22,11 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
assert!(prog.ends_with(".exe"));
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";
env = do env.map() |pair| {
env = env.map(|pair| {
let (k,v) = (*pair).clone();
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
else { (k,v) }
};
});
if prog.ends_with("rustc.exe") {
env.push((~"RUST_THREADS", ~"1"));
}

View File

@ -427,9 +427,9 @@ fn check_error_patterns(props: &TestProps,
testfile: &Path,
ProcRes: &ProcRes) {
if props.error_patterns.is_empty() {
do testfile.display().with_str |s| {
testfile.display().with_str(|s| {
fatal(~"no error pattern specified in " + s);
}
})
}
if ProcRes.status.success() {

View File

@ -333,47 +333,57 @@ mod test {
#[bench]
fn bench_capacity(b: &mut bh) {
let x = @[1, 2, 3];
b.iter(|| capacity(x));
b.iter(|| {
let _ = capacity(x);
});
}
#[bench]
fn bench_build_sized(b: &mut bh) {
let len = 64;
do b.iter {
b.iter(|| {
build(Some(len), |push| for i in range(0, 1024) { push(i) });
}
});
}
#[bench]
fn bench_build(b: &mut bh) {
do b.iter {
b.iter(|| {
for i in range(0, 95) {
build(None, |push| push(i));
}
}
});
}
#[bench]
fn bench_append(b: &mut bh) {
let lhs = @[7, ..128];
let rhs = range(0, 256).to_owned_vec();
b.iter(|| append(lhs, rhs))
b.iter(|| {
let _ = append(lhs, rhs);
})
}
#[bench]
fn bench_map(b: &mut bh) {
let elts = range(0, 256).to_owned_vec();
b.iter(|| map(elts, |x| x*2))
b.iter(|| {
let _ = map(elts, |x| x*2);
})
}
#[bench]
fn bench_from_fn(b: &mut bh) {
b.iter(|| from_fn(1024, |x| x));
b.iter(|| {
let _ = from_fn(1024, |x| x);
});
}
#[bench]
fn bench_from_elem(b: &mut bh) {
b.iter(|| from_elem(1024, 0u64));
b.iter(|| {
let _ = from_elem(1024, 0u64);
});
}
#[bench]
@ -387,12 +397,16 @@ mod test {
#[bench]
fn bench_to_managed(b: &mut bh) {
let elts = range(0, 1024).to_owned_vec();
b.iter(|| to_managed(elts));
b.iter(|| {
let _ = to_managed(elts);
});
}
#[bench]
fn bench_clone(b: &mut bh) {
let elts = to_managed(range(0, 1024).to_owned_vec());
b.iter(|| elts.clone());
b.iter(|| {
let _ = elts.clone();
});
}
}

View File

@ -53,9 +53,9 @@ use num::FromPrimitive;
/// # Examples
///
/// ```
/// do std::bool::all_values |x: bool| {
/// std::bool::all_values(|x: bool| {
/// println(x.to_str());
/// }
/// })
/// ```
#[inline]
pub fn all_values(blk: |v: bool|) {
@ -396,9 +396,9 @@ mod tests {
#[test]
fn test_bool_from_str() {
do all_values |v| {
all_values(|v| {
assert!(Some(v) == FromStr::from_str(v.to_str()))
}
});
}
#[test]
@ -409,11 +409,11 @@ mod tests {
#[test]
fn test_bool_to_bit() {
do all_values |v| {
all_values(|v| {
assert_eq!(v.to_bit::<u8>(), if v { 1u8 } else { 0u8 });
assert_eq!(v.to_bit::<uint>(), if v { 1u } else { 0u });
assert_eq!(v.to_bit::<int>(), if v { 1i } else { 0i });
}
});
}
#[test]

View File

@ -82,7 +82,6 @@ pub struct RefCell<T> {
priv nc: NonCopyable
}
<<<<<<< HEAD
// Values [1, MAX-1] represent the number of `Ref` active
// (will not outgrow its range since `uint` is the size of the address space)
type BorrowFlag = uint;

View File

@ -532,7 +532,7 @@ fn test_is_digit() {
fn test_escape_default() {
fn string(c: char) -> ~str {
let mut result = ~"";
do escape_default(c) |c| { result.push_char(c); }
escape_default(c, |c| { result.push_char(c); });
return result;
}
assert_eq!(string('\n'), ~"\\n");
@ -554,7 +554,7 @@ fn test_escape_default() {
fn test_escape_unicode() {
fn string(c: char) -> ~str {
let mut result = ~"";
do escape_unicode(c) |c| { result.push_char(c); }
escape_unicode(c, |c| { result.push_char(c); });
return result;
}
assert_eq!(string('\x00'), ~"\\x00");

View File

@ -224,14 +224,14 @@ mod test {
fn nested_trap_test_inner() {
let mut inner_trapped = false;
do sadness::cond.trap(|_j| {
sadness::cond.trap(|_j| {
debug!("nested_trap_test_inner: in handler");
inner_trapped = true;
0
}).inside {
}).inside(|| {
debug!("nested_trap_test_inner: in protected block");
trouble(1);
}
});
assert!(inner_trapped);
}
@ -240,14 +240,14 @@ mod test {
fn nested_trap_test_outer() {
let mut outer_trapped = false;
do sadness::cond.trap(|_j| {
sadness::cond.trap(|_j| {
debug!("nested_trap_test_outer: in handler");
outer_trapped = true; 0
}).inside {
}).inside(|| {
debug!("nested_guard_test_outer: in protected block");
nested_trap_test_inner();
trouble(1);
}
});
assert!(outer_trapped);
}
@ -255,16 +255,16 @@ mod test {
fn nested_reraise_trap_test_inner() {
let mut inner_trapped = false;
do sadness::cond.trap(|_j| {
sadness::cond.trap(|_j| {
debug!("nested_reraise_trap_test_inner: in handler");
inner_trapped = true;
let i = 10;
debug!("nested_reraise_trap_test_inner: handler re-raising");
sadness::cond.raise(i)
}).inside {
}).inside(|| {
debug!("nested_reraise_trap_test_inner: in protected block");
trouble(1);
}
});
assert!(inner_trapped);
}
@ -273,13 +273,13 @@ mod test {
fn nested_reraise_trap_test_outer() {
let mut outer_trapped = false;
do sadness::cond.trap(|_j| {
sadness::cond.trap(|_j| {
debug!("nested_reraise_trap_test_outer: in handler");
outer_trapped = true; 0
}).inside {
}).inside(|| {
debug!("nested_reraise_trap_test_outer: in protected block");
nested_reraise_trap_test_inner();
}
});
assert!(outer_trapped);
}
@ -288,13 +288,13 @@ mod test {
fn test_default() {
let mut trapped = false;
do sadness::cond.trap(|j| {
sadness::cond.trap(|j| {
debug!("test_default: in handler");
sadness::cond.raise_default(j, || { trapped=true; 5 })
}).inside {
}).inside(|| {
debug!("test_default: in protected block");
trouble(1);
}
});
assert!(trapped);
}
@ -312,12 +312,12 @@ mod test {
#[test]
fn test_conditions_are_public() {
let mut trapped = false;
do sadness::cond.trap(|_| {
sadness::cond.trap(|_| {
trapped = true;
0
}).inside {
}).inside(|| {
sadness::cond.raise(0);
}
});
assert!(trapped);
}
}

View File

@ -438,22 +438,22 @@ mod test {
#[bench]
fn bench_buffered_reader(bh: &mut Harness) {
do bh.iter {
bh.iter(|| {
BufferedReader::new(NullStream);
}
});
}
#[bench]
fn bench_buffered_writer(bh: &mut Harness) {
do bh.iter {
bh.iter(|| {
BufferedWriter::new(NullStream);
}
});
}
#[bench]
fn bench_buffered_stream(bh: &mut Harness) {
do bh.iter {
bh.iter(|| {
BufferedStream::new(NullStream);
}
});
}
}

View File

@ -276,11 +276,11 @@ mod test {
#[test]
fn read_byte_error() {
let mut reader = ErroringReader;
do io_error::cond.trap(|_| {
}).inside {
io_error::cond.trap(|_| {
}).inside(|| {
let byte = reader.read_byte();
assert!(byte == None);
}
});
}
#[test]
@ -303,10 +303,10 @@ mod test {
fn bytes_error() {
let reader = ErroringReader;
let mut it = reader.bytes();
do io_error::cond.trap(|_| ()).inside {
io_error::cond.trap(|_| ()).inside(|| {
let byte = it.next();
assert!(byte == None);
}
})
}
#[test]
@ -328,10 +328,10 @@ mod test {
#[test]
fn read_bytes_eof() {
let mut reader = MemReader::new(~[10, 11]);
do io_error::cond.trap(|_| {
}).inside {
io_error::cond.trap(|_| {
}).inside(|| {
assert!(reader.read_bytes(4) == ~[10, 11]);
}
})
}
#[test]
@ -356,11 +356,11 @@ mod test {
fn push_bytes_eof() {
let mut reader = MemReader::new(~[10, 11]);
let mut buf = ~[8, 9];
do io_error::cond.trap(|_| {
}).inside {
io_error::cond.trap(|_| {
}).inside(|| {
reader.push_bytes(&mut buf, 4);
assert!(buf == ~[8, 9, 10, 11]);
}
})
}
#[test]
@ -369,9 +369,9 @@ mod test {
count: 0,
};
let mut buf = ~[8, 9];
do io_error::cond.trap(|_| { } ).inside {
io_error::cond.trap(|_| { } ).inside(|| {
reader.push_bytes(&mut buf, 4);
}
});
assert!(buf == ~[8, 9, 10]);
}
@ -384,13 +384,13 @@ mod test {
count: 0,
};
let buf = @mut ~[8, 9];
do (|| {
(|| {
reader.push_bytes(&mut *buf, 4);
}).finally {
}).finally(|| {
// NB: Using rtassert here to trigger abort on failure since this is a should_fail test
// FIXME: #7049 This fails because buf is still borrowed
//rtassert!(*buf == ~[8, 9, 10]);
}
})
}
#[test]

View File

@ -331,12 +331,12 @@ mod test {
writer.write([0]);
let mut called = false;
do io_error::cond.trap(|err| {
io_error::cond.trap(|err| {
assert_eq!(err.kind, OtherIoError);
called = true;
}).inside {
}).inside(|| {
writer.write([0, 0]);
}
});
assert!(called);
}

View File

@ -157,14 +157,14 @@ mod test {
fn bind_error() {
do run_in_mt_newsched_task {
let mut called = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
assert!(e.kind == PermissionDenied);
called = true;
}).inside {
}).inside(|| {
let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
let listener = TcpListener::bind(addr);
assert!(listener.is_none());
}
});
assert!(called);
}
}
@ -173,7 +173,7 @@ mod test {
fn connect_error() {
do run_in_mt_newsched_task {
let mut called = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
let expected_error = if cfg!(unix) {
ConnectionRefused
} else {
@ -182,11 +182,11 @@ mod test {
};
assert_eq!(e.kind, expected_error);
called = true;
}).inside {
}).inside(|| {
let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
let stream = TcpStream::connect(addr);
assert!(stream.is_none());
}
});
assert!(called);
}
}
@ -306,16 +306,16 @@ mod test {
let mut buf = [0];
let nread = stream.read(buf);
assert!(nread.is_none());
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
if cfg!(windows) {
assert_eq!(e.kind, NotConnected);
} else {
fail!();
}
}).inside {
}).inside(|| {
let nread = stream.read(buf);
assert!(nread.is_none());
}
})
}
do spawntask {
@ -341,16 +341,16 @@ mod test {
let mut buf = [0];
let nread = stream.read(buf);
assert!(nread.is_none());
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
if cfg!(windows) {
assert_eq!(e.kind, NotConnected);
} else {
fail!();
}
}).inside {
}).inside(|| {
let nread = stream.read(buf);
assert!(nread.is_none());
}
})
}
do spawntask {
@ -376,7 +376,7 @@ mod test {
let buf = [0];
loop {
let mut stop = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
// NB: ECONNRESET on linux, EPIPE on mac, ECONNABORTED
// on windows
assert!(e.kind == ConnectionReset ||
@ -384,9 +384,9 @@ mod test {
e.kind == ConnectionAborted,
"unknown error: {:?}", e);
stop = true;
}).inside {
}).inside(|| {
stream.write(buf);
}
});
if stop { break }
}
}
@ -414,7 +414,7 @@ mod test {
let buf = [0];
loop {
let mut stop = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
// NB: ECONNRESET on linux, EPIPE on mac, ECONNABORTED
// on windows
assert!(e.kind == ConnectionReset ||
@ -422,9 +422,9 @@ mod test {
e.kind == ConnectionAborted,
"unknown error: {:?}", e);
stop = true;
}).inside {
}).inside(|| {
stream.write(buf);
}
});
if stop { break }
}
}
@ -458,10 +458,10 @@ mod test {
do spawntask {
port.take().recv();
do max.times {
max.times(|| {
let mut stream = TcpStream::connect(addr);
stream.write([99]);
}
});
}
}
}
@ -487,10 +487,10 @@ mod test {
do spawntask {
port.take().recv();
do max.times {
max.times(|| {
let mut stream = TcpStream::connect(addr);
stream.write([99]);
}
});
}
}
}

View File

@ -116,14 +116,14 @@ mod test {
fn bind_error() {
do run_in_mt_newsched_task {
let mut called = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
assert!(e.kind == PermissionDenied);
called = true;
}).inside {
}).inside(|| {
let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 1 };
let socket = UdpSocket::bind(addr);
assert!(socket.is_none());
}
});
assert!(called);
}
}

View File

@ -186,13 +186,13 @@ mod tests {
fn bind_error() {
do run_in_mt_newsched_task {
let mut called = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
assert!(e.kind == PermissionDenied);
called = true;
}).inside {
}).inside(|| {
let listener = UnixListener::bind(&("path/to/nowhere"));
assert!(listener.is_none());
}
});
assert!(called);
}
}
@ -201,13 +201,13 @@ mod tests {
fn connect_error() {
do run_in_mt_newsched_task {
let mut called = false;
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
assert_eq!(e.kind, OtherIoError);
called = true;
}).inside {
}).inside(|| {
let stream = UnixStream::connect(&("path/to/nowhere"));
assert!(stream.is_none());
}
});
assert!(called);
}
}
@ -240,13 +240,13 @@ mod tests {
let buf = [0];
let mut stop = false;
while !stop{
do io_error::cond.trap(|e| {
io_error::cond.trap(|e| {
assert!(e.kind == BrokenPipe || e.kind == NotConnected,
"unknown error {:?}", e);
stop = true;
}).inside {
}).inside(|| {
server.write(buf);
}
})
}
}, |_client| {
// drop the client
@ -266,20 +266,20 @@ mod tests {
do spawntask {
let mut acceptor = UnixListener::bind(&path1).listen();
chan.take().send(());
do times.times {
times.times(|| {
let mut client = acceptor.accept();
let mut buf = [0];
client.read(buf);
assert_eq!(buf[0], 100);
}
})
}
do spawntask {
port.take().recv();
do times.times {
times.times(|| {
let mut stream = UnixStream::connect(&path2);
stream.write([100]);
}
})
}
}
}

View File

@ -125,21 +125,21 @@ mod test {
let mut writer: Option<MemWriter> = None;
let mut called = false;
do io_error::cond.trap(|err| {
io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).inside {
}).inside(|| {
writer.write([0, 0, 0]);
}
});
assert!(called);
let mut called = false;
do io_error::cond.trap(|err| {
io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).inside {
}).inside(|| {
writer.flush();
}
});
assert!(called);
}
}
@ -161,21 +161,21 @@ mod test {
let mut buf = [];
let mut called = false;
do io_error::cond.trap(|err| {
io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).inside {
}).inside(|| {
reader.read(buf);
}
});
assert!(called);
let mut called = false;
do io_error::cond.trap(|err| {
io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).inside {
}).inside(|| {
assert!(reader.eof());
}
});
assert!(called);
}
}

View File

@ -2674,13 +2674,13 @@ mod tests {
fn test_rposition_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
let mut i = 0;
do v.iter().rposition |_elt| {
v.iter().rposition(|_elt| {
if i == 2 {
fail!()
}
i += 1;
false
};
});
}

View File

@ -479,19 +479,19 @@ mod tests {
static key: Key<~int> = &Key;
set(key, ~1);
do get(key) |v| {
do get(key) |v| {
do get(key) |v| {
get(key, |v| {
get(key, |v| {
get(key, |v| {
assert_eq!(**v.unwrap(), 1);
}
});
assert_eq!(**v.unwrap(), 1);
}
});
assert_eq!(**v.unwrap(), 1);
}
});
set(key, ~2);
do get(key) |v| {
get(key, |v| {
assert_eq!(**v.unwrap(), 2);
}
})
}
#[test]
@ -499,13 +499,13 @@ mod tests {
static key: Key<int> = &Key;
set(key, 1);
do get_mut(key) |v| {
get_mut(key, |v| {
*v.unwrap() = 2;
}
});
do get(key) |v| {
get(key, |v| {
assert_eq!(*v.unwrap(), 2);
}
})
}
#[test]
@ -533,9 +533,9 @@ mod tests {
fn test_nested_get_set1() {
static key: Key<int> = &Key;
set(key, 4);
do get(key) |_| {
get(key, |_| {
set(key, 4);
}
})
}
#[test]
@ -543,9 +543,9 @@ mod tests {
fn test_nested_get_mut2() {
static key: Key<int> = &Key;
set(key, 4);
do get(key) |_| {
get(key, |_| {
get_mut(key, |_| {})
}
})
}
#[test]
@ -553,9 +553,9 @@ mod tests {
fn test_nested_get_mut3() {
static key: Key<int> = &Key;
set(key, 4);
do get_mut(key) |_| {
get_mut(key, |_| {
get(key, |_| {})
}
})
}
#[test]
@ -563,8 +563,8 @@ mod tests {
fn test_nested_get_mut4() {
static key: Key<int> = &Key;
set(key, 4);
do get_mut(key) |_| {
get_mut(key, |_| {
get_mut(key, |_| {})
}
})
}
}

View File

@ -750,16 +750,16 @@ mod bench {
#[bench]
fn uint_to_str_rand(bh: &mut BenchHarness) {
let mut rng = XorShiftRng::new();
do bh.iter {
bh.iter(|| {
rng.gen::<uint>().to_str();
}
})
}
#[bench]
fn float_to_str_rand(bh: &mut BenchHarness) {
let mut rng = XorShiftRng::new();
do bh.iter {
bh.iter(|| {
f64::to_str(rng.gen());
}
})
}
}

View File

@ -244,6 +244,6 @@ pub fn test_times() {
use num::Times;
let ten = 10 as uint;
let mut accum = 0;
do ten.times { accum += 1; }
ten.times(|| { accum += 1; });
assert!((accum == 10));
}

View File

@ -612,14 +612,14 @@ mod tests {
#[test]
fn test_option_while_some() {
let mut i = 0;
do Some(10).while_some |j| {
Some(10).while_some(|j| {
i += 1;
if (j > 0) {
Some(j-1)
} else {
None
}
}
});
assert_eq!(i, 11);
}

View File

@ -523,35 +523,35 @@ mod tests {
use path::null_byte::cond;
let mut handled = false;
let mut p = do cond.trap(|v| {
let mut p = cond.trap(|v| {
handled = true;
assert_eq!(v.as_slice(), b!("foo/bar", 0));
(b!("/bar").to_owned())
}).inside {
}).inside(|| {
Path::new(b!("foo/bar", 0))
};
});
assert!(handled);
assert_eq!(p.as_vec(), b!("/bar"));
handled = false;
do cond.trap(|v| {
cond.trap(|v| {
handled = true;
assert_eq!(v.as_slice(), b!("f", 0, "o"));
(b!("foo").to_owned())
}).inside {
}).inside(|| {
p.set_filename(b!("f", 0, "o"))
};
});
assert!(handled);
assert_eq!(p.as_vec(), b!("/foo"));
handled = false;
do cond.trap(|v| {
cond.trap(|v| {
handled = true;
assert_eq!(v.as_slice(), b!("f", 0, "o"));
(b!("foo").to_owned())
}).inside {
}).inside(|| {
p.push(b!("f", 0, "o"));
};
});
assert!(handled);
assert_eq!(p.as_vec(), b!("/foo/foo"));
}
@ -573,29 +573,29 @@ mod tests {
)
t!(~"new() w/nul" => {
do cond.trap(|_| {
cond.trap(|_| {
(b!("null", 0).to_owned())
}).inside {
}).inside(|| {
Path::new(b!("foo/bar", 0))
};
});
})
t!(~"set_filename w/nul" => {
let mut p = Path::new(b!("foo/bar"));
do cond.trap(|_| {
cond.trap(|_| {
(b!("null", 0).to_owned())
}).inside {
}).inside(|| {
p.set_filename(b!("foo", 0))
};
});
})
t!(~"push w/nul" => {
let mut p = Path::new(b!("foo/bar"));
do cond.trap(|_| {
cond.trap(|_| {
(b!("null", 0).to_owned())
}).inside {
}).inside(|| {
p.push(b!("foo", 0))
};
});
})
}
@ -621,10 +621,10 @@ mod tests {
{
let mut called = false;
let path = Path::new($path);
do path.display().with_str |s| {
path.display().with_str(|s| {
assert_eq!(s, $exp);
called = true;
};
});
assert!(called);
}
);
@ -632,11 +632,10 @@ mod tests {
{
let mut called = false;
let path = Path::new($path);
do path.filename_display().with_str |s| {
path.filename_display().with_str(|s| {
assert_eq!(s, $exp);
called = true;
};
});
assert!(called);
}
)

View File

@ -1248,35 +1248,35 @@ mod tests {
use path::null_byte::cond;
let mut handled = false;
let mut p = do cond.trap(|v| {
let mut p = cond.trap(|v| {
handled = true;
assert_eq!(v.as_slice(), b!("foo\\bar", 0));
(b!("\\bar").to_owned())
}).inside {
}).inside(|| {
Path::new(b!("foo\\bar", 0))
};
});
assert!(handled);
assert_eq!(p.as_vec(), b!("\\bar"));
handled = false;
do cond.trap(|v| {
cond.trap(|v| {
handled = true;
assert_eq!(v.as_slice(), b!("f", 0, "o"));
(b!("foo").to_owned())
}).inside {
}).inside(|| {
p.set_filename(b!("f", 0, "o"))
};
});
assert!(handled);
assert_eq!(p.as_vec(), b!("\\foo"));
handled = false;
do cond.trap(|v| {
cond.trap(|v| {
handled = true;
assert_eq!(v.as_slice(), b!("f", 0, "o"));
(b!("foo").to_owned())
}).inside {
}).inside(|| {
p.push(b!("f", 0, "o"));
};
});
assert!(handled);
assert_eq!(p.as_vec(), b!("\\foo\\foo"));
}
@ -1298,29 +1298,29 @@ mod tests {
)
t!(~"from_vec() w\\nul" => {
do cond.trap(|_| {
cond.trap(|_| {
(b!("null", 0).to_owned())
}).inside {
}).inside(|| {
Path::new(b!("foo\\bar", 0))
};
});
})
t!(~"set_filename w\\nul" => {
let mut p = Path::new(b!("foo\\bar"));
do cond.trap(|_| {
cond.trap(|_| {
(b!("null", 0).to_owned())
}).inside {
}).inside(|| {
p.set_filename(b!("foo", 0))
};
});
})
t!(~"push w\\nul" => {
let mut p = Path::new(b!("foo\\bar"));
do cond.trap(|_| {
cond.trap(|_| {
(b!("null", 0).to_owned())
}).inside {
}).inside(|| {
p.push(b!("foo", 0))
};
});
})
}
@ -1339,17 +1339,17 @@ mod tests {
let mut called = false;
let path = Path::new("foo");
do path.display().with_str |s| {
path.display().with_str(|s| {
assert_eq!(s, "foo");
called = true;
};
});
assert!(called);
called = false;
let path = Path::new(b!("\\"));
do path.filename_display().with_str |s| {
path.filename_display().with_str(|s| {
assert_eq!(s, "");
called = true;
}
});
assert!(called);
}

View File

@ -492,28 +492,28 @@ pub mod ptr_tests {
fn test_position() {
use libc::c_char;
do "hello".with_c_str |p| {
"hello".with_c_str(|p| {
unsafe {
assert!(2u == position(p, |c| *c == 'l' as c_char));
assert!(4u == position(p, |c| *c == 'o' as c_char));
assert!(5u == position(p, |c| *c == 0 as c_char));
}
}
})
}
#[test]
fn test_buf_len() {
do "hello".with_c_str |p0| {
do "there".with_c_str |p1| {
do "thing".with_c_str |p2| {
"hello".with_c_str(|p0| {
"there".with_c_str(|p1| {
"thing".with_c_str(|p2| {
let v = ~[p0, p1, p2, null()];
do v.as_imm_buf |vp, len| {
v.as_imm_buf(|vp, len| {
assert_eq!(unsafe { buf_len(vp) }, 3u);
assert_eq!(len, 4u);
}
}
}
}
})
})
})
})
}
#[test]
@ -621,23 +621,23 @@ pub mod ptr_tests {
one, two, three
];
do arr.as_imm_buf |arr_ptr, arr_len| {
arr.as_imm_buf(|arr_ptr, arr_len| {
let mut ctr = 0;
let mut iteration_count = 0;
do array_each_with_len(arr_ptr, arr_len) |e| {
array_each_with_len(arr_ptr, arr_len, |e| {
let actual = str::raw::from_c_str(e);
let expected = do expected_arr[ctr].with_ref |buf| {
let expected = expected_arr[ctr].with_ref(|buf| {
str::raw::from_c_str(buf)
};
});
debug!(
"test_ptr_array_each_with_len e: {}, a: {}",
expected, actual);
assert_eq!(actual, expected);
ctr += 1;
iteration_count += 1;
}
});
assert_eq!(iteration_count, 3u);
}
})
}
}
@ -658,23 +658,23 @@ pub mod ptr_tests {
one, two, three
];
do arr.as_imm_buf |arr_ptr, _| {
arr.as_imm_buf(|arr_ptr, _| {
let mut ctr = 0;
let mut iteration_count = 0;
do array_each(arr_ptr) |e| {
array_each(arr_ptr, |e| {
let actual = str::raw::from_c_str(e);
let expected = do expected_arr[ctr].with_ref |buf| {
let expected = expected_arr[ctr].with_ref(|buf| {
str::raw::from_c_str(buf)
};
});
debug!(
"test_ptr_array_each e: {}, a: {}",
expected, actual);
assert_eq!(actual, expected);
ctr += 1;
iteration_count += 1;
}
});
assert_eq!(iteration_count, 3);
}
})
}
}

View File

@ -184,11 +184,11 @@ mod bench {
let gamma = Gamma::new(10., 1.0);
let mut rng = StdRng::new();
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
gamma.ind_sample(&mut rng);
}
}
});
bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
}
@ -197,11 +197,11 @@ mod bench {
let gamma = Gamma::new(0.1, 1.0);
let mut rng = StdRng::new();
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
gamma.ind_sample(&mut rng);
}
}
});
bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
}
}

View File

@ -571,11 +571,11 @@ mod bench {
let mut rng = XorShiftRng::new();
let mut normal = Normal::new(-2.71828, 3.14159);
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
normal.sample(&mut rng);
}
}
});
bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
}
#[bench]
@ -583,11 +583,11 @@ mod bench {
let mut rng = XorShiftRng::new();
let mut exp = Exp::new(2.71828 * 3.14159);
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
exp.sample(&mut rng);
}
}
});
bh.bytes = size_of::<f64>() as u64 * RAND_BENCH_N;
}
}

View File

@ -899,44 +899,44 @@ mod bench {
#[bench]
fn rand_xorshift(bh: &mut BenchHarness) {
let mut rng = XorShiftRng::new();
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
rng.gen::<uint>();
}
}
});
bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
}
#[bench]
fn rand_isaac(bh: &mut BenchHarness) {
let mut rng = IsaacRng::new();
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
rng.gen::<uint>();
}
}
});
bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
}
#[bench]
fn rand_isaac64(bh: &mut BenchHarness) {
let mut rng = Isaac64Rng::new();
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
rng.gen::<uint>();
}
}
});
bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
}
#[bench]
fn rand_std(bh: &mut BenchHarness) {
let mut rng = StdRng::new();
do bh.iter {
bh.iter(|| {
for _ in range(0, RAND_BENCH_N) {
rng.gen::<uint>();
}
}
});
bh.bytes = size_of::<uint>() as u64 * RAND_BENCH_N;
}
@ -944,8 +944,8 @@ mod bench {
fn rand_shuffle_100(bh: &mut BenchHarness) {
let mut rng = XorShiftRng::new();
let x : &mut[uint] = [1,..100];
do bh.iter {
bh.iter(|| {
rng.shuffle_mut(x);
}
})
}
}

View File

@ -139,9 +139,9 @@ impl<T, E: ToStr> Result<T, E> {
///
/// Example:
///
/// let res = do read_file(file).map |buf| {
/// let res = read_file(file).map(|buf| {
/// parse_bytes(buf)
/// }
/// })
#[inline]
pub fn map<U>(self, op: |T| -> U) -> Result<U,E> {
match self {
@ -462,11 +462,11 @@ mod tests {
pub fn test_impl_iter() {
let mut valid = false;
let okval = Ok::<~str, ~str>(~"a");
do okval.iter().next().map |_| { valid = true; };
okval.iter().next().map(|_| { valid = true; });
assert!(valid);
let errval = Err::<~str, ~str>(~"b");
do errval.iter().next().map |_| { valid = false; };
errval.iter().next().map(|_| { valid = false; });
assert!(valid);
}
@ -474,12 +474,12 @@ mod tests {
pub fn test_impl_iter_err() {
let mut valid = true;
let okval = Ok::<~str, ~str>(~"a");
do okval.iter_err().next().map |_| { valid = false };
okval.iter_err().next().map(|_| { valid = false });
assert!(valid);
valid = false;
let errval = Err::<~str, ~str>(~"b");
do errval.iter_err().next().map |_| { valid = true };
errval.iter_err().next().map(|_| { valid = true });
assert!(valid);
}

View File

@ -1013,7 +1013,7 @@ mod test {
total.times(|| {
port.recv();
})
});
}
}
@ -1041,7 +1041,7 @@ mod test {
total.times(|| {
end_port.recv();
})
});
}
}
@ -1071,7 +1071,7 @@ mod test {
do spawntask_random {
chan_clone.send(());
}
})
});
}
let end_chan_clone = end_chan.clone();
do spawntask_random {
@ -1082,7 +1082,7 @@ mod test {
let recvd = port_clone.try_recv().is_some();
end_chan_clone.send(recvd);
}
})
});
}
let mut recvd = 0;
@ -1112,12 +1112,12 @@ mod test {
let pipe_clone = pipe.clone();
let end_chan_clone = end_chan.clone();
do spawntask_random {
do msgs.times {
msgs.times(|| {
pipe_clone.send(());
}
do msgs.times {
});
msgs.times(|| {
pipe_clone.recv();
}
});
}
end_chan_clone.send(());
@ -1125,7 +1125,7 @@ mod test {
total.times(|| {
end_port.recv();
})
});
}
}

View File

@ -61,9 +61,9 @@ pub fn get_crate_map() -> Option<&'static CrateMap<'static>> {
} else {
"_rust_crate_map_toplevel"
};
let sym = do rust_crate_map_toplevel.with_c_str |buf| {
let sym = rust_crate_map_toplevel.with_c_str(|buf| {
dl::symbol(module, buf)
};
});
dl::close(module);
sym
};
@ -141,10 +141,10 @@ mod tests {
let mut cnt = 0;
unsafe {
do iter_crate_map(&root_crate) |entry| {
iter_crate_map(&root_crate, |entry| {
assert!(*entry.log_level == 3);
cnt += 1;
}
});
assert!(cnt == 1);
}
}
@ -183,10 +183,10 @@ mod tests {
let mut cnt = 0;
unsafe {
do iter_crate_map(&root_crate) |entry| {
iter_crate_map(&root_crate, |entry| {
assert!(*entry.log_level == cnt);
cnt += 1;
}
});
assert!(cnt == 4);
}
}

View File

@ -103,15 +103,15 @@ mod bench {
#[bench]
fn alloc_owned_small(bh: &mut BenchHarness) {
do bh.iter {
bh.iter(|| {
~10;
}
})
}
#[bench]
fn alloc_owned_big(bh: &mut BenchHarness) {
do bh.iter {
bh.iter(|| {
~[10, ..1000];
}
})
}
}

View File

@ -182,9 +182,9 @@ mod test {
let task = ~Task::new_root(&mut sched.stack_pool, None, || {});
Local::put(task);
let res = do Local::borrow |_task: &mut Task| {
let res = Local::borrow(|_task: &mut Task| {
true
};
});
assert!(res)
let task: ~Task = Local::take();
cleanup_task(task);

View File

@ -311,11 +311,11 @@ mod bench {
#[bench]
fn alloc_managed_small(bh: &mut BenchHarness) {
bh.iter(|| @10);
bh.iter(|| { @10; });
}
#[bench]
fn alloc_managed_big(bh: &mut BenchHarness) {
bh.iter(|| @[10, ..1000]);
bh.iter(|| { @[10, ..1000]; });
}
}

View File

@ -1176,7 +1176,7 @@ mod test {
use util;
do run_in_bare_thread {
do stress_factor().times {
stress_factor().times(|| {
let sleepers = SleeperList::new();
let queue = WorkQueue::new();
let queues = ~[queue.clone()];
@ -1205,7 +1205,7 @@ mod test {
util::ignore(handle);
thread.join();
}
})
}
}
@ -1218,14 +1218,14 @@ mod test {
do run_in_mt_newsched_task {
let mut ports = ~[];
do 10.times {
10.times(|| {
let (port, chan) = oneshot();
let chan_cell = Cell::new(chan);
do spawntask_later {
chan_cell.take().send(());
}
ports.push(port);
}
});
while !ports.is_empty() {
ports.pop().recv();
@ -1315,7 +1315,7 @@ mod test {
fn dont_starve_1() {
use rt::comm::oneshot;
do stress_factor().times {
stress_factor().times(|| {
do run_in_mt_newsched_task {
let (port, chan) = oneshot();
@ -1327,14 +1327,14 @@ mod test {
chan.send(());
}
}
})
}
#[test]
fn dont_starve_2() {
use rt::comm::oneshot;
do stress_factor().times {
stress_factor().times(|| {
do run_in_newsched_task {
let (port, chan) = oneshot();
let (_port2, chan2) = stream();
@ -1349,7 +1349,7 @@ mod test {
chan.send(());
}
}
})
}
// Regression test for a logic bug that would cause single-threaded schedulers
@ -1360,7 +1360,7 @@ mod test {
use num::Times;
do spawn_sched(SingleThreaded) {
do 5.times { deschedule(); }
5.times(|| { deschedule(); })
}
do spawn { }
do spawn { }

View File

@ -103,11 +103,11 @@ mod test {
let tube_clone = tube.clone();
let tube_clone_cell = Cell::new(tube_clone);
let sched: ~Scheduler = Local::take();
do sched.deschedule_running_task_and_then |sched, task| {
sched.deschedule_running_task_and_then(|sched, task| {
let mut tube_clone = tube_clone_cell.take();
tube_clone.send(1);
sched.enqueue_blocked_task(task);
}
});
assert!(tube.recv() == 1);
}
@ -120,7 +120,7 @@ mod test {
let tube_clone = tube.clone();
let tube_clone = Cell::new(tube_clone);
let sched: ~Scheduler = Local::take();
do sched.deschedule_running_task_and_then |sched, task| {
sched.deschedule_running_task_and_then(|sched, task| {
let tube_clone = Cell::new(tube_clone.take());
do sched.event_loop.callback {
let mut tube_clone = tube_clone.take();
@ -129,7 +129,7 @@ mod test {
tube_clone.send(1);
}
sched.enqueue_blocked_task(task);
}
});
assert!(tube.recv() == 1);
}
@ -144,14 +144,14 @@ mod test {
let tube_clone = tube.clone();
let tube_clone = Cell::new(tube_clone);
let sched: ~Scheduler = Local::take();
do sched.deschedule_running_task_and_then |sched, task| {
sched.deschedule_running_task_and_then(|sched, task| {
callback_send(tube_clone.take(), 0);
fn callback_send(tube: Tube<int>, i: int) {
if i == 100 { return; }
let tube = Cell::new(Cell::new(tube));
do Local::borrow |sched: &mut Scheduler| {
Local::borrow(|sched: &mut Scheduler| {
let tube = tube.take();
do sched.event_loop.callback {
let mut tube = tube.take();
@ -160,11 +160,11 @@ mod test {
tube.send(i);
callback_send(tube, i + 1);
}
}
})
}
sched.enqueue_blocked_task(task);
}
});
for i in range(0, MAX) {
let j = tube.recv();

View File

@ -211,7 +211,7 @@ mod test {
do run_in_uv_task {
let (ports, _) = unzip(range(0u, 10).map(|_| stream::<int>()));
let (port, chan) = stream();
do 10.times { chan.send(31337); }
10.times(|| { chan.send(31337); });
let mut ports = ports;
let mut port = Some(port);
let order = [5u,0,4,3,2,6,9,8,7,1];
@ -276,7 +276,7 @@ mod test {
do run_in_uv_task {
// A bit of stress, since ordinarily this is just smoke and mirrors.
do 4.times {
4.times(|| {
let send_on_chans = send_on_chans.clone();
do task::spawn {
let mut ports = ~[];
@ -294,7 +294,7 @@ mod test {
// nondeterministic result, but should succeed
select(ports);
}
}
})
}
}
}

View File

@ -3966,19 +3966,25 @@ mod bench {
Lorem ipsum dolor sit amet, consectetur. ");
assert_eq!(100, s.len());
bh.iter(|| is_utf8(s));
bh.iter(|| {
let _ = is_utf8(s);
});
}
#[bench]
fn is_utf8_100_multibyte(bh: &mut BenchHarness) {
let s = bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰");
assert_eq!(100, s.len());
bh.iter(|| is_utf8(s));
bh.iter(|| {
let _ = is_utf8(s);
});
}
#[bench]
fn bench_with_capacity(bh: &mut BenchHarness) {
bh.iter(|| with_capacity(100));
bh.iter(|| {
let _ = with_capacity(100);
});
}
#[bench]

View File

@ -477,9 +477,9 @@ fn test_unnamed_task() {
do run_in_uv_task {
do spawn {
do with_task_name |name| {
with_task_name(|name| {
assert!(name.is_none());
}
})
}
}
}
@ -492,9 +492,9 @@ fn test_owned_named_task() {
let mut t = task();
t.name(~"ada lovelace");
do t.spawn {
do with_task_name |name| {
with_task_name(|name| {
assert!(name.unwrap() == "ada lovelace");
}
})
}
}
}
@ -507,9 +507,9 @@ fn test_static_named_task() {
let mut t = task();
t.name("ada lovelace");
do t.spawn {
do with_task_name |name| {
with_task_name(|name| {
assert!(name.unwrap() == "ada lovelace");
}
})
}
}
}
@ -522,9 +522,9 @@ fn test_send_named_task() {
let mut t = task();
t.name("ada lovelace".into_send_str());
do t.spawn {
do with_task_name |name| {
with_task_name(|name| {
assert!(name.unwrap() == "ada lovelace");
}
})
}
}
}
@ -606,9 +606,9 @@ fn test_try_fail() {
#[cfg(test)]
fn get_sched_id() -> int {
do Local::borrow |sched: &mut ::rt::sched::Scheduler| {
Local::borrow(|sched: &mut ::rt::sched::Scheduler| {
sched.sched_id() as int
}
})
}
#[test]
@ -666,7 +666,7 @@ fn test_spawn_sched_blocking() {
// Testing that a task in one scheduler can block in foreign code
// without affecting other schedulers
do 20u.times {
20u.times(|| {
let (start_po, start_ch) = stream();
let (fin_po, fin_ch) = stream();
@ -713,7 +713,7 @@ fn test_spawn_sched_blocking() {
lock.unlock();
fin_po.recv();
lock.destroy();
}
})
}
}
@ -740,21 +740,21 @@ fn test_avoid_copying_the_body_spawn() {
#[test]
fn test_avoid_copying_the_body_task_spawn() {
do avoid_copying_the_body |f| {
avoid_copying_the_body(|f| {
let builder = task();
do builder.spawn || {
f();
}
}
})
}
#[test]
fn test_avoid_copying_the_body_try() {
do avoid_copying_the_body |f| {
avoid_copying_the_body(|f| {
do try || {
f()
};
}
})
}
#[test]

View File

@ -15,11 +15,11 @@ stack closures that emulates Java-style try/finally blocks.
# Example
```
do || {
(|| {
...
}.finally {
}).finally(|| {
always_run_this();
}
})
```
*/
@ -70,13 +70,13 @@ impl<'self> Drop for Finallyalizer<'self> {
#[test]
fn test_success() {
let mut i = 0;
do (|| {
(|| {
i = 10;
}).finally {
}).finally(|| {
assert!(!failing());
assert_eq!(i, 10);
i = 20;
}
});
assert_eq!(i, 20);
}
@ -84,19 +84,19 @@ fn test_success() {
#[should_fail]
fn test_fail() {
let mut i = 0;
do (|| {
(|| {
i = 10;
fail!();
}).finally {
}).finally(|| {
assert!(failing());
assert_eq!(i, 10);
}
})
}
#[test]
fn test_retval() {
let closure: || -> int = || 10;
let i = do closure.finally { };
let i = closure.finally(|| { });
assert_eq!(i, 10);
}

View File

@ -178,17 +178,17 @@ mod bench {
fn trait_vtable_method_call(bh: &mut BenchHarness) {
let s = Struct { field: 10 };
let t = &s as &Trait;
do bh.iter {
bh.iter(|| {
t.method();
}
});
}
#[bench]
fn trait_static_method_call(bh: &mut BenchHarness) {
let s = Struct { field: 10 };
do bh.iter {
bh.iter(|| {
s.method();
}
});
}
// Overhead of various match forms
@ -196,22 +196,22 @@ mod bench {
#[bench]
fn match_option_some(bh: &mut BenchHarness) {
let x = Some(10);
do bh.iter {
bh.iter(|| {
let _q = match x {
Some(y) => y,
None => 11
};
}
});
}
#[bench]
fn match_vec_pattern(bh: &mut BenchHarness) {
let x = [1,2,3,4,5,6];
do bh.iter {
bh.iter(|| {
let _q = match x {
[1,2,3,.._] => 10,
_ => 11
};
}
});
}
}

View File

@ -3878,13 +3878,17 @@ mod bench {
#[bench]
fn concat(bh: &mut BenchHarness) {
let xss: &[~[uint]] = vec::from_fn(100, |i| range(0, i).collect());
bh.iter(|| xss.concat_vec());
bh.iter(|| {
let _ = xss.concat_vec();
});
}
#[bench]
fn connect(bh: &mut BenchHarness) {
let xss: &[~[uint]] = vec::from_fn(100, |i| range(0, i).collect());
bh.iter(|| xss.connect_vec(&0));
bh.iter(|| {
let _ = xss.connect_vec(&0);
});
}
#[bench]

View File

@ -15,7 +15,7 @@ condition! {
}
pub fn guard(k: extern fn() -> int, x: int) -> int {
do oops::cond.trap(|i| i*x).inside {
oops::cond.trap(|i| i*x).inside(|| {
k()
}
})
}

View File

@ -14,8 +14,6 @@ use extra::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
do x.write_cond |_one, cond| {
y = Some(cond);
}
x.write_cond(|_one, cond| y = Some(cond));
y.unwrap().wait();
}

View File

@ -13,10 +13,10 @@ use extra::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
do x.write_downgrade |write_mode| {
x.write_downgrade(|write_mode| {
y = Some(x.downgrade(write_mode));
//~^ ERROR cannot infer an appropriate lifetime
}
});
y.unwrap();
// Adding this line causes a method unification failure instead
// do (&option::unwrap(y)).read |state| { assert!(*state == 1); }

View File

@ -13,9 +13,7 @@ use extra::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None; //~ ERROR lifetime of variable does not enclose its declaration
do x.write |one| {
y = Some(one);
}
x.write(|one| y = Some(one));
*y.unwrap() = 2;
//~^ ERROR lifetime of return value does not outlive the function call
//~^^ ERROR dereference of reference outside its lifetime

View File

@ -14,10 +14,10 @@ use extra::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
do x.write_downgrade |write_mode| {
do (&write_mode).write_cond |_one, cond| {
x.write_downgrade(|write_mode| {
(&write_mode).write_cond(|_one, cond| {
y = Some(cond);
}
}
})
});
y.unwrap().wait();
}

View File

@ -14,9 +14,7 @@ use extra::arc;
fn main() {
let x = ~arc::RWArc::new(1);
let mut y = None;
do x.write_downgrade |write_mode| {
y = Some(write_mode);
}
x.write_downgrade(|write_mode| y = Some(write_mode));
y.unwrap();
// Adding this line causes a method unification failure instead
// do (&option::unwrap(y)).write |state| { assert!(*state == 1); }

View File

@ -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 compute1() -> f64 {
let v = ~[0f64, 1.0, 2.0, 3.0];
do v.iter().fold(0.0) |x, y| { x + *y } - 10.0
//~^ ERROR mismatched types: expected `()`
}
fn main() {
let x = compute1();
info!("{:?}", x);
assert_eq!(x, -4f64);
}

View File

@ -32,9 +32,9 @@ fn b() {
let mut p = ~[1];
do borrow(p) {
borrow(p, || {
p[0] = 5; //~ ERROR cannot assign to
}
});
}
fn c() {

View File

@ -18,7 +18,7 @@ impl X {
fn main() {
let mut x = X(Right(main));
do (&mut x).with |opt| {
(&mut x).with(|opt| {
match opt {
&Right(ref f) => {
x = X(Left((0,0))); //~ ERROR cannot assign to `x`
@ -26,5 +26,5 @@ fn main() {
},
_ => fail!()
}
}
})
}

View File

@ -23,9 +23,9 @@ impl Foo {
}
fn bar(f: &mut Foo) {
do f.foo |a| {
f.foo(|a| {
f.n.insert(*a); //~ ERROR cannot borrow
}
})
}
fn main() {

View File

@ -39,9 +39,9 @@ fn block_overarching_alias_mut() {
let mut v = ~3;
let mut x = &mut v;
do 3.times {
3.times(|| {
borrow(v); //~ ERROR cannot borrow
}
});
*x = ~5;
}

View File

@ -14,11 +14,11 @@ fn borrow(v: &int, f: |x: &int|) {
fn box_imm() {
let mut v = ~3;
do borrow(v) |w| {
borrow(v, |w| {
v = ~4; //~ ERROR cannot assign to `v` because it is borrowed
assert_eq!(*v, 3);
assert_eq!(*w, 4);
}
})
}
fn main() {

View File

@ -30,9 +30,9 @@ fn a() {
p.impurem();
// But in this case we do not honor the loan:
do p.blockm {
p.blockm(|| {
p.x = 10; //~ ERROR cannot assign
}
})
}
fn b() {
@ -52,9 +52,9 @@ fn c() {
q.impurem();
// ...but we still detect errors statically when we can.
do q.blockm {
q.blockm(|| {
q.x = 10; //~ ERROR cannot assign
}
})
}
fn main() {

View File

@ -18,15 +18,14 @@ fn takes_imm_elt(_v: &int, f: ||) {
fn has_mut_vec_and_does_not_try_to_change_it() {
let mut v = ~[1, 2, 3];
do takes_imm_elt(&v[0]) {
}
takes_imm_elt(&v[0], || {})
}
fn has_mut_vec_but_tries_to_change_it() {
let mut v = ~[1, 2, 3];
do takes_imm_elt(&v[0]) {
takes_imm_elt(&v[0], || {
v[1] = 4; //~ ERROR cannot assign
}
})
}
fn main() {

View File

@ -23,10 +23,10 @@ fn main() {
while cond() {
if cond() { break }
if cond() { continue }
do foo {
foo(|| {
if cond() { break } //~ ERROR: `break` inside of a closure
if cond() { continue } //~ ERROR: `continue` inside of a closure
}
})
}
let rs: Foo = Foo{t: pth};

View File

@ -12,9 +12,9 @@ fn bar(blk: ||:'static) {
}
fn foo(x: &()) {
do bar {
bar(|| {
let _ = x; //~ ERROR does not fulfill `'static`
}
})
}
fn main() {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f(f: |int| -> bool) -> bool { f(10i) }
fn f(f: proc(int) -> bool) -> bool { f(10i) }
fn main() {
assert!(do f() |i| { i == 10i } == 10i);

View File

@ -35,9 +35,9 @@ fn main() {
let mut a = ~[];
a.push(3);
let mut a = ~[];
do callback {
callback(|| {
a.push(3);
}
});
let (mut a, b) = (1, 2);
a = 34;

View File

@ -24,7 +24,7 @@ unsafe fn unsf() {}
fn bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block
unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block
fn bad4() { unsafe { do callback {} } } //~ ERROR: unnecessary `unsafe` block
fn bad4() { unsafe { callback(||{}) } } //~ ERROR: unnecessary `unsafe` block
unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block
fn bad6() {
unsafe { // don't put the warning here
@ -50,9 +50,9 @@ fn good2() {
unsafe {
unsafe fn what() -> ~[~str] { fail!() }
do callback {
callback(|| {
what();
}
});
}
}

View File

@ -15,12 +15,12 @@ fn f(s: &S, g: |&S|) {
fn main() {
let s = S { x: ~Bar(~42) };
loop {
do f(&s) |hellothere| {
f(&s, |hellothere| {
match hellothere.x {
~Foo(_) => {}
~Bar(x) => println(x.to_str()), //~ ERROR cannot move out
~Baz => {}
}
}
})
}
}

View File

@ -21,7 +21,7 @@ struct R<'self> {
fn innocent_looking_victim() {
let mut x = Some(~"hello");
do conspirator |f, writer| {
conspirator(|f, writer| {
if writer {
x = None;
} else {
@ -33,7 +33,7 @@ fn innocent_looking_victim() {
None => fail!("oops"),
}
}
}
})
}
fn conspirator(f: |&R, bool|) {

View File

@ -18,8 +18,8 @@ fn test_mutex_arc_nested() {
let arc2 = ~MutexArc::new(*arc);
do task::spawn || {
do (*arc2).access |mutex| { //~ ERROR instantiating a type parameter with an incompatible type
}
(*arc2).access(|mutex| { //~ ERROR instantiating a type parameter with an incompatible type
})
};
}

View File

@ -23,8 +23,8 @@ fn foo(blk: once ||) {
fn main() {
let x = arc::Arc::new(true);
do foo {
foo(|| {
assert!(*x.get());
util::ignore(x);
}
})
}

View File

@ -22,8 +22,8 @@ fn foo(blk: ||) {
fn main() {
let x = arc::Arc::new(true);
do foo {
foo(|| {
assert!(*x.get());
util::ignore(x); //~ ERROR cannot move out of captured outer variable
}
})
}

View File

@ -12,7 +12,7 @@ fn wants_static_fn(_x: 'static ||) {}
fn main() {
let i = 3;
do wants_static_fn { //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
wants_static_fn(|| { //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
info!("i={}", i);
}
})
}

View File

@ -15,7 +15,7 @@ fn with<T>(f: |x: &int| -> T) -> T {
}
fn manip<'a>(x: &'a int) -> int {
let z = do with |y| { select(x, y) };
let z = with(|y| { select(x, y) });
//~^ ERROR cannot infer an appropriate lifetime
*z
}

View File

@ -15,8 +15,8 @@ use extra::sync;
fn main() {
let m = ~sync::Mutex::new();
let mut cond = None;
do m.lock_cond |c| {
m.lock_cond(|c| {
cond = Some(c);
}
});
cond.unwrap().signal();
}

View File

@ -14,8 +14,8 @@ use extra::sync;
fn main() {
let x = ~sync::RWLock::new();
let mut y = None;
do x.write_cond |cond| {
x.write_cond(|cond| {
y = Some(cond);
}
});
y.unwrap().wait();
}

View File

@ -14,9 +14,9 @@ use extra::sync;
fn main() {
let x = ~sync::RWLock::new();
let mut y = None;
do x.write_downgrade |write_mode| {
x.write_downgrade(|write_mode| {
y = Some(x.downgrade(write_mode));
}
})
// Adding this line causes a method unification failure instead
// do (&option::unwrap(y)).read { }
}

View File

@ -14,10 +14,10 @@ use extra::sync;
fn main() {
let x = ~sync::RWLock::new();
let mut y = None;
do x.write_downgrade |write_mode| {
do (&write_mode).write_cond |cond| {
x.write_downgrade(|write_mode| {
(&write_mode).write_cond(|cond| {
y = Some(cond);
}
}
})
});
y.unwrap().wait();
}

View File

@ -14,9 +14,9 @@ use extra::sync;
fn main() {
let x = ~sync::RWLock::new();
let mut y = None;
do x.write_downgrade |write_mode| {
x.write_downgrade(|write_mode| {
y = Some(write_mode);
}
});
// Adding this line causes a method unification failure instead
// do (&option::unwrap(y)).write { }
}

View File

@ -21,7 +21,7 @@ fn main() {
// huge).
let x = ~[1u,2u,3u];
do x.as_imm_buf |p, _len| {
x.as_imm_buf(|p, _len| {
let base = p as uint;
let idx = base / mem::size_of::<uint>();
error!("ov1 base = 0x{:x}", base);
@ -32,5 +32,5 @@ fn main() {
// This should fail.
error!("ov1 0x{:x}", x[idx]);
}
})
}

View File

@ -30,14 +30,17 @@ impl<A> iterable<A> for ~[A] {
fn length<A, T: iterable<A>>(x: T) -> uint {
let mut len = 0;
do x.iterate() |_y| { len += 1; true };
x.iterate(|_y| {
len += 1;
true
});
return len;
}
pub fn main() {
let x = ~[0,1,2,3];
// Call a method
do x.iterate() |y| { assert!(x[*y] == *y); true };
x.iterate(|y| { assert!(x[*y] == *y); true });
// Call a parameterized function
assert_eq!(length(x.clone()), x.len());
// Call a parameterized function, with type arguments that require
@ -47,7 +50,7 @@ pub fn main() {
// Now try it with a type that *needs* to be borrowed
let z = [0,1,2,3];
// Call a method
do z.iterate() |y| { assert!(z[*y] == *y); true };
z.iterate(|y| { assert!(z[*y] == *y); true });
// Call a parameterized function
assert_eq!(length::<int, &[int]>(z), z.len());
}

View File

@ -20,5 +20,5 @@ fn bitv_test() {
}
pub fn main() {
do 10000.times || {bitv_test()};
10000.times(|| bitv_test());
}

View File

@ -8,11 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0];
// Trailing expressions don't require parentheses:
let y = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0;
assert_eq!(y, 15.0);
fn add(x: proc(f64) -> f64) -> f64 {
x(10.0)
}
pub fn main() {
// Trailing expressions don't require parentheses:
let y = do add |x| { x + 10.0 } + 10.0;
assert_eq!(y, 30.0);
}

View File

@ -8,9 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn main() {
fn f(i: || -> uint) -> uint { i() }
let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0];
let z = do do v.iter().fold(f) |x, _y| { x } { 22u };
assert_eq!(z, 22u);
fn f(_: proc()) -> proc(proc() -> uint) {
proc(_: proc() -> uint) {}
}
pub fn main() {
do do f {} { 20 };
}

View File

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f(_: proc()) -> proc(uint) -> uint {
proc(x: uint) { x }
}
pub fn main() {
fn f(i: uint) -> uint { i }
let v = ~[-1.0, 0.0, 1.0, 2.0, 3.0];
let z = do v.iter().fold(f) |x, _y| { x } (22u);
let z = do f {} (22u);
assert_eq!(z, 22u);
}

View File

@ -8,28 +8,31 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn w_semi(v: ~[int]) -> int {
fn f(_: proc(int, int) -> int) -> int {
10
}
fn w_semi() {
// the semicolon causes compiler not to
// complain about the ignored return value:
do v.iter().fold(0) |x,y| { x+*y };
-10
do f |x, y| { x+y };
}
fn w_paren1(v: ~[int]) -> int {
(do v.iter().fold(0) |x,y| { x+*y }) - 10
fn w_paren1() -> int {
(do f |x, y| { x+y }) - 10
}
fn w_paren2(v: ~[int]) -> int {
(do v.iter().fold(0) |x,y| { x+*y} - 10)
fn w_paren2() -> int {
(do f |x, y| { x+y } - 10)
}
fn w_ret(v: ~[int]) -> int {
return do v.iter().fold(0) |x,y| { x+*y } - 10;
fn w_ret() -> int {
return do f |x, y| { x+y } - 10;
}
pub fn main() {
assert_eq!(w_semi(~[0, 1, 2, 3]), -10);
assert_eq!(w_paren1(~[0, 1, 2, 3]), -4);
assert_eq!(w_paren2(~[0, 1, 2, 3]), -4);
assert_eq!(w_ret(~[0, 1, 2, 3]), -4);
w_semi();
w_paren1();
w_paren2();
w_ret();
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn call_any(f: || -> uint) -> uint {
fn call_any(f: proc() -> uint) -> uint {
return f();
}

View File

@ -8,6 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn inty(fun: proc(int) -> int) -> int {
fun(100)
}
fn booly(fun: proc(bool) -> bool) -> bool {
fun(true)
}
// Check usage and precedence of block arguments in expressions:
pub fn main() {
let v = ~[-1.0f64, 0.0, 1.0, 2.0, 3.0];
@ -18,28 +26,27 @@ pub fn main() {
}
// Usable at all:
let mut any_negative = do v.iter().any |e| { e.is_negative() };
assert!(any_negative);
do inty |x| { x };
// Higher precedence than assignments:
any_negative = do v.iter().any |e| { e.is_negative() };
assert!(any_negative);
let result = do inty |e| { e };
assert_eq!(result, 100);
// Higher precedence than unary operations:
let abs_v = do v.iter().map |e| { e.abs() }.collect::<~[f64]>();
assert!(do abs_v.iter().all |e| { e.is_positive() });
assert!(!do abs_v.iter().any |e| { e.is_negative() });
let stringy = do inty |e| { e }.to_str();
assert!(do booly |_| { true });
assert!(!do booly |_| { false });
// Usable in funny statement-like forms:
if !do v.iter().any |e| { e.is_positive() } {
if !do booly |_| { true } {
assert!(false);
}
match do v.iter().all |e| { e.is_negative() } {
match do booly |_| { false } {
true => { fail!("incorrect answer."); }
false => { }
}
match 3 {
_ if do v.iter().any |e| { e.is_negative() } => {
_ if do booly |_| { true } => {
}
_ => {
fail!("wrong answer.");
@ -48,15 +55,19 @@ pub fn main() {
// Lower precedence than binary operations:
let w = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0;
let y = do v.iter().fold(0.0) |x, y| { x + *y } + 10.0;
let z = 10.0 + do v.iter().fold(0.0) |x, y| { x + *y };
let w = do inty |_| { 10 } + 10;
let y = do inty |_| { 10 } + 10;
let z = 10 + do inty |_| { 10 };
assert_eq!(w, y);
assert_eq!(y, z);
// In the tail of a block
let w =
if true { do abs_v.iter().any |e| { e.is_positive() } }
else { false };
let w = if true {
do booly |_| {
true
}
} else {
false
};
assert!(w);
}

View File

@ -18,11 +18,11 @@ fn borrow(x: &int, f: |x: &int|) {
}
fn test1(x: @~int) {
do borrow(&*(*x).clone()) |p| {
borrow(&*(*x).clone(), |p| {
let x_a = ptr::to_unsafe_ptr(&**x);
assert!((x_a as uint) != borrow::to_uint(p));
assert_eq!(unsafe{*x_a}, *p);
}
})
}
pub fn main() {

View File

@ -30,10 +30,10 @@ pub fn main() {
add_int(ints, 22);
add_int(ints, 44);
do iter_ints(ints) |i| {
iter_ints(ints, |i| {
error!("int = {}", *i);
true
};
});
error!("ints={:?}", ints);
}

View File

@ -23,7 +23,7 @@ struct F { f: ~int }
pub fn main() {
let mut x = @F {f: ~3};
do borrow(x.f) |b_x| {
borrow(x.f, |b_x| {
assert_eq!(*b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
x = @F {f: ~4};
@ -32,5 +32,5 @@ pub fn main() {
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
}
})
}

View File

@ -23,7 +23,7 @@ struct F { f: ~int }
pub fn main() {
let mut x = ~@F{f: ~3};
do borrow(x.f) |b_x| {
borrow(x.f, |b_x| {
assert_eq!(*b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
*x = @F{f: ~4};
@ -32,5 +32,5 @@ pub fn main() {
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
}
})
}

View File

@ -21,7 +21,7 @@ fn borrow(x: &int, f: |x: &int|) {
pub fn main() {
let mut x = @3;
do borrow(x) |b_x| {
borrow(x, |b_x| {
assert_eq!(*b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(*x)), ptr::to_unsafe_ptr(&(*b_x)));
x = @22;
@ -30,5 +30,5 @@ pub fn main() {
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x)));
}
})
}

View File

@ -23,7 +23,7 @@ struct F { f: ~int }
pub fn main() {
let mut x = @F {f: ~3};
do borrow((*x).f) |b_x| {
borrow((*x).f, |b_x| {
assert_eq!(*b_x, 3);
assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x)));
x = @F {f: ~4};
@ -32,5 +32,5 @@ pub fn main() {
ptr::to_unsafe_ptr(&(*b_x)) as uint);
assert_eq!(*b_x, 3);
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
}
})
}

View File

@ -18,11 +18,11 @@ pub fn main() {
//let bt0 = sys::frame_address();
//info!("%?", bt0);
do 3u.to(10u) |i| {
3u.to(10u, |i| {
println!("{}", i);
//let bt1 = sys::frame_address();
//info!("%?", bt1);
//assert!(bt0 == bt1);
}
})
}

View File

@ -16,8 +16,8 @@ extern mod cci_iter_lib;
pub fn main() {
//let bt0 = sys::rusti::frame_address(1u32);
//info!("%?", bt0);
do cci_iter_lib::iter([1, 2, 3]) |i| {
cci_iter_lib::iter([1, 2, 3], |i| {
println!("{}", *i);
//assert!(bt0 == sys::rusti::frame_address(2u32));
}
})
}

View File

@ -22,12 +22,12 @@ pub fn main() {
// actually working.
//let bt0 = sys::frame_address();
//info!("%?", bt0);
do iter(~[1u, 2u, 3u]) |i| {
iter(~[1u, 2u, 3u], |i| {
println!("{}", i);
//let bt1 = sys::frame_address();
//info!("%?", bt1);
//assert!(bt0 != bt1);
}
})
}

View File

@ -40,9 +40,9 @@ fn test_destroy_twice() {
let mut p = run::Process::new(PROG, [], run::ProcessOptions::new());
p.destroy(); // this shouldnt crash...
do io::io_error::cond.trap(|_| {}).inside {
io::io_error::cond.trap(|_| {}).inside(|| {
p.destroy(); // ...and nor should this (and nor should the destructor)
}
})
}
fn test_destroy_actually_kills(force: bool) {

View File

@ -71,9 +71,9 @@ pub fn main() {
roundtrip::<C>();
roundtrip::<D>();
do 20.times {
20.times(|| {
roundtrip::<E>();
roundtrip::<F>();
roundtrip::<G<int>>();
}
})
}

View File

@ -34,10 +34,10 @@ enum D {
fn main() {
// check there's no segfaults
do 20.times {
20.times(|| {
rand::random::<A>();
rand::random::<B>();
rand::random::<C>();
rand::random::<D>();
}
})
}

View File

@ -11,7 +11,7 @@
// no-reformat
// Testing various forms of `do` with empty arg lists
fn f(_f: || -> bool) -> bool {
fn f(_f: proc() -> bool) -> bool {
true
}

View File

@ -10,9 +10,9 @@
// Testing that we can drop the || in do exprs
fn f(_f: || -> bool) -> bool { true }
fn f(_f: proc() -> bool) -> bool { true }
fn d(_f: ||) { }
fn d(_f: proc()) { }
pub fn main() {
do d { }

View File

@ -1,20 +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 f(_f: ||) {
}
fn g() {
// `f || { }` is considered pure, so `do f { }` should be too
do f { }
}
pub fn main() {
}

View File

@ -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.
fn f(f: |int|) { f(10) }
pub fn main() {
do f() |i| { assert!(i == 10) }
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f(f: |int|) { f(10) }
fn f(f: proc(int)) { f(10) }
pub fn main() {
do f() |i| { assert!(i == 10) }

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f(f: |int| -> int) -> int { f(10) }
fn f(f: proc(int) -> int) -> int { f(10) }
pub fn main() {
assert_eq!(do f() |i| { i }, 10);

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn f(f: |int| -> int) -> int { f(10) }
fn f(f: proc(int) -> int) -> int { f(10) }
pub fn main() {
assert_eq!(do f |i| { i }, 10);

Some files were not shown because too many files have changed in this diff Show More