Skip to content

Commit 219a302

Browse files
committed
---
yaml --- r: 51034 b: refs/heads/try c: b10b8c3 h: refs/heads/master v: v3
1 parent 92d061f commit 219a302

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
5-
refs/heads/try: c9188c83015e25978b9c6c4864040dd958bc54b1
5+
refs/heads/try: b10b8c3ee41447299504127c341bc363d180356c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/json.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,8 @@ mod tests {
12361236
use core::prelude::*;
12371237
use core::hashmap::linear::LinearMap;
12381238
1239+
use std::serialize::Decodable;
1240+
12391241
fn mk_object(items: &[(~str, Json)]) -> Json {
12401242
let mut d = ~LinearMap::new();
12411243
@@ -1389,6 +1391,8 @@ mod tests {
13891391
}
13901392
13911393
#[auto_encode]
1394+
#[auto_decode]
1395+
#[deriving(Eq)]
13921396
enum Animal {
13931397
Dog,
13941398
Frog(~str, int)
@@ -1706,6 +1710,20 @@ mod tests {
17061710
]));
17071711
}
17081712
1713+
#[test]
1714+
fn test_read_none() {
1715+
let decoder = Decoder(from_str(~"null").unwrap());
1716+
let value: Option<~str> = Decodable::decode(&decoder);
1717+
assert_eq!(value, None);
1718+
}
1719+
1720+
#[test]
1721+
fn test_read_some() {
1722+
let decoder = Decoder(from_str(~"\"jodhpurs\"").unwrap());
1723+
let value: Option<~str> = Decodable::decode(&decoder);
1724+
assert_eq!(value, Some(~"jodhpurs"));
1725+
}
1726+
17091727
#[test]
17101728
fn test_multiline_errors() {
17111729
assert_eq!(from_str(~"{\n \"foo\":\n \"bar\""),

branches/try/src/libsyntax/parse/mod.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,30 @@ mod test {
326326
@~"fn foo (x : int) { x; }",
327327
~[],
328328
new_parse_sess(None));
329-
assert_eq!(to_json_str(@tts),
330-
~"[[\"tt_tok\",[null,[\"IDENT\",[\"fn\",false]]]],\
331-
[\"tt_tok\",[null,[\"IDENT\",[\"foo\",false]]]],\
332-
[\"tt_delim\",[[[\"tt_tok\",[null,[\"LPAREN\",[]]]],\
333-
[\"tt_tok\",[null,[\"IDENT\",[\"x\",false]]]],\
334-
[\"tt_tok\",[null,[\"COLON\",[]]]],\
335-
[\"tt_tok\",[null,[\"IDENT\",[\"int\",false]]]],\
336-
[\"tt_tok\",[null,[\"RPAREN\",[]]]]]]],\
337-
[\"tt_delim\",[[[\"tt_tok\",[null,[\"LBRACE\",[]]]],\
338-
[\"tt_tok\",[null,[\"IDENT\",[\"x\",false]]]],\
339-
[\"tt_tok\",[null,[\"SEMI\",[]]]],\
340-
[\"tt_tok\",[null,[\"RBRACE\",[]]]]]]]]"
341-
);
329+
assert_eq!(
330+
to_json_str(@tts),
331+
~"[\
332+
[\"tt_tok\",[null,[\"IDENT\",[\"fn\",false]]]],\
333+
[\"tt_tok\",[null,[\"IDENT\",[\"foo\",false]]]],\
334+
[\"tt_delim\",[\
335+
[\
336+
[\"tt_tok\",[null,[\"LPAREN\",[]]]],\
337+
[\"tt_tok\",[null,[\"IDENT\",[\"x\",false]]]],\
338+
[\"tt_tok\",[null,[\"COLON\",[]]]],\
339+
[\"tt_tok\",[null,[\"IDENT\",[\"int\",false]]]],\
340+
[\"tt_tok\",[null,[\"RPAREN\",[]]]]\
341+
]\
342+
]],\
343+
[\"tt_delim\",[\
344+
[\
345+
[\"tt_tok\",[null,[\"LBRACE\",[]]]],\
346+
[\"tt_tok\",[null,[\"IDENT\",[\"x\",false]]]],\
347+
[\"tt_tok\",[null,[\"SEMI\",[]]]],\
348+
[\"tt_tok\",[null,[\"RBRACE\",[]]]]\
349+
]\
350+
]]\
351+
]"
352+
);
342353
let ast1 = new_parser_from_tts(new_parse_sess(None),~[],tts)
343354
.parse_item(~[]);
344355
let ast2 = parse_item_from_source_str(

0 commit comments

Comments
 (0)