Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: trunk/src/third_party/JSON/JSON-2.59/t/06_pc_pretty.t

Issue 16539003: Revert 205057 "Add JSON.pm to third_party" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #! perl
2
3 # copied over from JSON::PC and modified to use JSON
4 # copied over from JSON::XS and modified to use JSON
5
6 use strict;
7 use Test::More;
8 BEGIN { plan tests => 9 };
9
10 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
11
12 use JSON;
13
14 my ($js,$obj,$json);
15 my $pc = new JSON;
16
17 $obj = {foo => "bar"};
18 $js = $pc->encode($obj);
19 is($js,q|{"foo":"bar"}|);
20
21 $obj = [10, "hoge", {foo => "bar"}];
22 $pc->pretty (1);
23 $js = $pc->encode($obj);
24 is($js,q|[
25 10,
26 "hoge",
27 {
28 "foo" : "bar"
29 }
30 ]
31 |);
32
33 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
34 $pc->pretty(0);
35 $js = $pc->encode($obj);
36 is($js,q|{"foo":[{"a":"b"},0,1,2]}|);
37
38
39 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
40 $pc->pretty(1);
41 $js = $pc->encode($obj);
42 is($js,q|{
43 "foo" : [
44 {
45 "a" : "b"
46 },
47 0,
48 1,
49 2
50 ]
51 }
52 |);
53
54 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
55 $pc->pretty(0);
56 $js = $pc->encode($obj);
57 is($js,q|{"foo":[{"a":"b"},0,1,2]}|);
58
59
60 $obj = {foo => "bar"};
61 $pc->indent(3); # original -- $pc->indent(1);
62 is($pc->encode($obj), qq|{\n "foo":"bar"\n}\n|, "nospace");
63 $pc->space_after(1);
64 is($pc->encode($obj), qq|{\n "foo": "bar"\n}\n|, "after");
65 $pc->space_before(1);
66 is($pc->encode($obj), qq|{\n "foo" : "bar"\n}\n|, "both");
67 $pc->space_after(0);
68 is($pc->encode($obj), qq|{\n "foo" :"bar"\n}\n|, "before");
69
OLDNEW
« no previous file with comments | « trunk/src/third_party/JSON/JSON-2.59/t/03_types.t ('k') | trunk/src/third_party/JSON/JSON-2.59/t/07_pc_esc.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698