auto merge of #8069 : erickt/rust/maikklein, r=erickt
Good evening, This is a superset of @MaikKlein's #7969 commit, that I've fixed up to compile. I had a couple commits I wanted to do on top of @MaikKlein's work that I didn't want to bitrot.
This commit is contained in:
commit
20454da2db
15 changed files with 410 additions and 467 deletions
|
|
@ -1867,27 +1867,26 @@ mod tests {
|
|||
col: 8u,
|
||||
msg: @~"EOF while parsing object"}));
|
||||
|
||||
assert_eq!(result::unwrap(from_str("{}")), mk_object([]));
|
||||
assert_eq!(result::unwrap(from_str("{\"a\": 3}")),
|
||||
assert_eq!(from_str("{}").unwrap(), mk_object([]));
|
||||
assert_eq!(from_str("{\"a\": 3}").unwrap(),
|
||||
mk_object([(~"a", Number(3.0f))]));
|
||||
|
||||
assert_eq!(result::unwrap(from_str(
|
||||
"{ \"a\": null, \"b\" : true }")),
|
||||
assert_eq!(from_str(
|
||||
"{ \"a\": null, \"b\" : true }").unwrap(),
|
||||
mk_object([
|
||||
(~"a", Null),
|
||||
(~"b", Boolean(true))]));
|
||||
assert_eq!(result::unwrap(
|
||||
from_str("\n{ \"a\": null, \"b\" : true }\n")),
|
||||
assert_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(),
|
||||
mk_object([
|
||||
(~"a", Null),
|
||||
(~"b", Boolean(true))]));
|
||||
assert_eq!(result::unwrap(from_str(
|
||||
"{\"a\" : 1.0 ,\"b\": [ true ]}")),
|
||||
assert_eq!(from_str(
|
||||
"{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(),
|
||||
mk_object([
|
||||
(~"a", Number(1.0)),
|
||||
(~"b", List(~[Boolean(true)]))
|
||||
]));
|
||||
assert_eq!(result::unwrap(from_str(
|
||||
assert_eq!(from_str(
|
||||
~"{" +
|
||||
"\"a\": 1.0, " +
|
||||
"\"b\": [" +
|
||||
|
|
@ -1895,7 +1894,7 @@ mod tests {
|
|||
"\"foo\\nbar\", " +
|
||||
"{ \"c\": {\"d\": null} } " +
|
||||
"]" +
|
||||
"}")),
|
||||
"}").unwrap(),
|
||||
mk_object([
|
||||
(~"a", Number(1.0f)),
|
||||
(~"b", List(~[
|
||||
|
|
|
|||
|
|
@ -1132,13 +1132,13 @@ mod tests {
|
|||
assert!(test("6", "%w"));
|
||||
assert!(test("2009", "%Y"));
|
||||
assert!(test("09", "%y"));
|
||||
assert!(result::unwrap(strptime("UTC", "%Z")).tm_zone ==
|
||||
assert!(strptime("UTC", "%Z").unwrap().tm_zone ==
|
||||
~"UTC");
|
||||
assert!(result::unwrap(strptime("PST", "%Z")).tm_zone ==
|
||||
assert!(strptime("PST", "%Z").unwrap().tm_zone ==
|
||||
~"");
|
||||
assert!(result::unwrap(strptime("-0000", "%z")).tm_gmtoff ==
|
||||
assert!(strptime("-0000", "%z").unwrap().tm_gmtoff ==
|
||||
0);
|
||||
assert!(result::unwrap(strptime("-0800", "%z")).tm_gmtoff ==
|
||||
assert!(strptime("-0800", "%z").unwrap().tm_gmtoff ==
|
||||
0);
|
||||
assert!(test("%", "%%"));
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use std::cell::Cell;
|
|||
use std::comm::{PortOne, oneshot, send_one, recv_one};
|
||||
use std::either::{Either, Left, Right};
|
||||
use std::io;
|
||||
use std::result;
|
||||
use std::run;
|
||||
use std::task;
|
||||
|
||||
|
|
@ -208,7 +207,7 @@ fn json_encode<T:Encodable<json::Encoder>>(t: &T) -> ~str {
|
|||
// FIXME(#5121)
|
||||
fn json_decode<T:Decodable<json::Decoder>>(s: &str) -> T {
|
||||
do io::with_str_reader(s) |rdr| {
|
||||
let j = result::unwrap(json::from_reader(rdr));
|
||||
let j = json::from_reader(rdr).unwrap();
|
||||
let mut decoder = json::Decoder(j);
|
||||
Decodable::decode(&mut decoder)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue