-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// xfail-fast
-// xfail-test needs networking
+// ignore-test needs networking
-extern mod extra;
+extern crate extra;
use extra::net::tcp::TcpSocketBuf;
}
priv fn parse_list(len: uint, io: @io::Reader) -> Result {
- let mut list: ~[Result] = ~[];
- do len.times {
- let v =
- match io.read_char() {
- '$' => parse_bulk(io),
- ':' => parse_int(io),
- _ => fail!()
- };
- list.push(v);
+ let mut list: ~[Result] = ~[];
+ for _ in range(0, len) {
+ let v = match io.read_char() {
+ '$' => parse_bulk(io),
+ ':' => parse_int(io),
+ _ => fail!()
+ };
+ list.push(v);
}
- return List(list);
+ return List(list);
}
priv fn chop(s: ~str) -> ~str {
}
priv fn cmd_to_str(cmd: ~[~str]) -> ~str {
- let mut res = ~"*";
+ let mut res = "*".to_owned();
res.push_str(cmd.len().to_str());
res.push_str("\r\n");
for s in cmd.iter() {
- res.push_str([~"$", s.len().to_str(), ~"\r\n",
- (*s).clone(), ~"\r\n"].concat() );
+ res.push_str(["$".to_owned(), s.len().to_str(), "\r\n".to_owned(),
+ (*s).clone(), "\r\n".to_owned()].concat() );
}
res
}
fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result {
let cmd = cmd_to_str(cmd);
- //io::println(cmd);
+ //println!("{}", cmd);
sb.write_str(cmd);
let res = parse_response(@sb as @io::Reader);
res
fn query2(cmd: ~[~str]) -> Result {
let _cmd = cmd_to_str(cmd);
- do io::with_str_reader(~"$3\r\nXXX\r\n") |sb| {
+ io::with_str_reader("$3\r\nXXX\r\n".to_owned())(|sb| {
let res = parse_response(@sb as @io::Reader);
println!("{:?}", res);
res
- }
+ });
}