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

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

Issue 15736030: Add JSON.pm to third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix permissions and shebangs 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
« no previous file with comments | « third_party/JSON/JSON-2.59/t/03_types.t ('k') | third_party/JSON/JSON-2.59/t/07_pc_esc.t » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1
2 # copied over from JSON::PC and modified to use JSON
3 # copied over from JSON::XS and modified to use JSON
4
5 use strict;
6 use Test::More;
7 BEGIN { plan tests => 9 };
8
9 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
10
11 use JSON;
12
13 my ($js,$obj,$json);
14 my $pc = new JSON;
15
16 $obj = {foo => "bar"};
17 $js = $pc->encode($obj);
18 is($js,q|{"foo":"bar"}|);
19
20 $obj = [10, "hoge", {foo => "bar"}];
21 $pc->pretty (1);
22 $js = $pc->encode($obj);
23 is($js,q|[
24 10,
25 "hoge",
26 {
27 "foo" : "bar"
28 }
29 ]
30 |);
31
32 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
33 $pc->pretty(0);
34 $js = $pc->encode($obj);
35 is($js,q|{"foo":[{"a":"b"},0,1,2]}|);
36
37
38 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
39 $pc->pretty(1);
40 $js = $pc->encode($obj);
41 is($js,q|{
42 "foo" : [
43 {
44 "a" : "b"
45 },
46 0,
47 1,
48 2
49 ]
50 }
51 |);
52
53 $obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
54 $pc->pretty(0);
55 $js = $pc->encode($obj);
56 is($js,q|{"foo":[{"a":"b"},0,1,2]}|);
57
58
59 $obj = {foo => "bar"};
60 $pc->indent(3); # original -- $pc->indent(1);
61 is($pc->encode($obj), qq|{\n "foo":"bar"\n}\n|, "nospace");
62 $pc->space_after(1);
63 is($pc->encode($obj), qq|{\n "foo": "bar"\n}\n|, "after");
64 $pc->space_before(1);
65 is($pc->encode($obj), qq|{\n "foo" : "bar"\n}\n|, "both");
66 $pc->space_after(0);
67 is($pc->encode($obj), qq|{\n "foo" :"bar"\n}\n|, "before");
68
OLDNEW
« no previous file with comments | « third_party/JSON/JSON-2.59/t/03_types.t ('k') | 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