Skip to content

Commit 068e9b3

Browse files
committed
---
yaml --- r: 139373 b: refs/heads/try2 c: b10b8c3 h: refs/heads/master i: 139371: 6828c19 v: v3
1 parent 03e64d9 commit 068e9b3

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c9188c83015e25978b9c6c4864040dd958bc54b1
8+
refs/heads/try2: b10b8c3ee41447299504127c341bc363d180356c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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/try2/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)