Skip to content

Commit 80fda81

Browse files
committed
---
yaml --- r: 14555 b: refs/heads/try c: 3d104cf h: refs/heads/master i: 14553: 089c28a 14551: 3ec6daf v: v3
1 parent a22bda4 commit 80fda81

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 4be92670a4ad505ba669549317e9929335d8f18f
5+
refs/heads/try: 3d104cfb410211cb313a50c6cdb8b652f62ce9f4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libstd/json.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ impl parser for parser {
154154
fn parse() -> result::t<json, error> {
155155
alt self.parse_value() {
156156
ok(value) {
157+
// Skip trailing whitespaces.
158+
self.parse_whitespace();
157159
// Make sure there is no trailing characters.
158160
if self.eof() {
159161
ok(value)
@@ -627,6 +629,9 @@ mod tests {
627629
assert from_str("null") == ok(null);
628630
assert from_str("true") == ok(boolean(true));
629631
assert from_str("false") == ok(boolean(false));
632+
assert from_str(" null ") == ok(null);
633+
assert from_str(" true ") == ok(boolean(true));
634+
assert from_str(" false ") == ok(boolean(false));
630635
}
631636

632637
#[test]
@@ -654,6 +659,7 @@ mod tests {
654659
assert from_str("0.4e5") == ok(num(0.4e5f));
655660
assert from_str("0.4e+15") == ok(num(0.4e15f));
656661
assert from_str("0.4e-01") == ok(num(0.4e-01f));
662+
assert from_str(" 3 ") == ok(num(3f));
657663
}
658664

659665
#[test]
@@ -670,6 +676,7 @@ mod tests {
670676
assert from_str("\"\\n\"") == ok(string("\n"));
671677
assert from_str("\"\\r\"") == ok(string("\r"));
672678
assert from_str("\"\\t\"") == ok(string("\t"));
679+
assert from_str(" \"foo\" ") == ok(string("foo"));
673680
}
674681

675682
#[test]
@@ -691,6 +698,7 @@ mod tests {
691698
assert from_str("[ false ]") == ok(list([boolean(false)]));
692699
assert from_str("[null]") == ok(list([null]));
693700
assert from_str("[3, 1]") == ok(list([num(3f), num(1f)]));
701+
assert from_str("\n[3, 2]\n") == ok(list([num(3f), num(2f)]));
694702
assert from_str("[2, [4, 1]]") ==
695703
ok(list([num(2f), list([num(4f), num(1f)])]));
696704
}
@@ -727,6 +735,8 @@ mod tests {
727735

728736
assert eq(result::get(from_str("{ \"a\": null, \"b\" : true }")),
729737
mk_dict([("a", null), ("b", boolean(true))]));
738+
assert eq(result::get(from_str("\n{ \"a\": null, \"b\" : true }\n")),
739+
mk_dict([("a", null), ("b", boolean(true))]));
730740
assert eq(result::get(from_str("{\"a\" : 1.0 ,\"b\": [ true ]}")),
731741
mk_dict([
732742
("a", num(1.0)),

0 commit comments

Comments
 (0)