Skip to content

Commit 2a883cc

Browse files
committed
---
yaml --- r: 139377 b: refs/heads/try2 c: 4e9a63f h: refs/heads/master i: 139375: 74af96e v: v3
1 parent 10b5f9d commit 2a883cc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
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: 4d6dcefcbb8688b69dd80bc7382a2f593c3b08d8
8+
refs/heads/try2: 4e9a63ff917af32bd9ddfee65f5871a5586771e1
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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ impl<'self> serialize::Decoder for Decoder<'self> {
851851
852852
fn read_enum<T>(&self, name: &str, f: &fn() -> T) -> T {
853853
debug!("read_enum(%s)", name);
854-
if name != ~"option" { fail!(~"only supports the option enum") }
855854
f()
856855
}
857856
@@ -1720,6 +1719,20 @@ mod tests {
17201719
assert_eq!(value, Some(~"jodhpurs"));
17211720
}
17221721
1722+
#[test]
1723+
fn test_read_enum_no_args() {
1724+
let decoder = Decoder(from_str(~"\"Dog\"").unwrap());
1725+
let value: Animal = Decodable::decode(&decoder);
1726+
assert_eq!(value, Dog);
1727+
}
1728+
1729+
#[test]
1730+
fn test_read_enum_multiple_args() {
1731+
let decoder = Decoder(from_str(~"[\"Frog\",\"Henry\",349]").unwrap());
1732+
let value: Animal = Decodable::decode(&decoder);
1733+
assert_eq!(value, Frog(~"Henry", 349));
1734+
}
1735+
17231736
#[test]
17241737
fn test_multiline_errors() {
17251738
assert_eq!(from_str(~"{\n \"foo\":\n \"bar\""),

0 commit comments

Comments
 (0)