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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/JSON/JSON-2.59/t/06_pc_pretty.t
diff --git a/third_party/JSON/JSON-2.59/t/06_pc_pretty.t b/third_party/JSON/JSON-2.59/t/06_pc_pretty.t
new file mode 100644
index 0000000000000000000000000000000000000000..8c90e2881148a85a8745cec3908c611614863f81
--- /dev/null
+++ b/third_party/JSON/JSON-2.59/t/06_pc_pretty.t
@@ -0,0 +1,68 @@
+
+# copied over from JSON::PC and modified to use JSON
+# copied over from JSON::XS and modified to use JSON
+
+use strict;
+use Test::More;
+BEGIN { plan tests => 9 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
+
+use JSON;
+
+my ($js,$obj,$json);
+my $pc = new JSON;
+
+$obj = {foo => "bar"};
+$js = $pc->encode($obj);
+is($js,q|{"foo":"bar"}|);
+
+$obj = [10, "hoge", {foo => "bar"}];
+$pc->pretty (1);
+$js = $pc->encode($obj);
+is($js,q|[
+ 10,
+ "hoge",
+ {
+ "foo" : "bar"
+ }
+]
+|);
+
+$obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
+$pc->pretty(0);
+$js = $pc->encode($obj);
+is($js,q|{"foo":[{"a":"b"},0,1,2]}|);
+
+
+$obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
+$pc->pretty(1);
+$js = $pc->encode($obj);
+is($js,q|{
+ "foo" : [
+ {
+ "a" : "b"
+ },
+ 0,
+ 1,
+ 2
+ ]
+}
+|);
+
+$obj = { foo => [ {a=>"b"}, 0, 1, 2 ] };
+$pc->pretty(0);
+$js = $pc->encode($obj);
+is($js,q|{"foo":[{"a":"b"},0,1,2]}|);
+
+
+$obj = {foo => "bar"};
+$pc->indent(3); # original -- $pc->indent(1);
+is($pc->encode($obj), qq|{\n "foo":"bar"\n}\n|, "nospace");
+$pc->space_after(1);
+is($pc->encode($obj), qq|{\n "foo": "bar"\n}\n|, "after");
+$pc->space_before(1);
+is($pc->encode($obj), qq|{\n "foo" : "bar"\n}\n|, "both");
+$pc->space_after(0);
+is($pc->encode($obj), qq|{\n "foo" :"bar"\n}\n|, "before");
+
« 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