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

Side by Side Diff: third_party/JSON/JSON-2.59/t/e04_sortby.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/e03_bool2.t ('k') | third_party/JSON/JSON-2.59/t/e05_esc_slash.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 use Test::More;
3 use strict;
4 BEGIN { plan tests => 3 };
5 BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
6 use JSON;
7 #########################
8
9 my ($js,$obj);
10 my $pc = JSON->new;
11
12 $obj = {a=>1, b=>2, c=>3, d=>4, e=>5, f=>6, g=>7, h=>8, i=>9};
13
14 $js = $pc->sort_by(1)->encode($obj);
15 is($js, q|{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9}|);
16
17
18 $js = $pc->sort_by(sub { $JSON::PP::a cmp $JSON::PP::b })->encode($obj);
19 is($js, q|{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9}|);
20
21 $js = $pc->sort_by('hoge')->encode($obj);
22 is($js, q|{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9}|);
23
24 sub JSON::PP::hoge { $JSON::PP::a cmp $JSON::PP::b }
OLDNEW
« no previous file with comments | « third_party/JSON/JSON-2.59/t/e03_bool2.t ('k') | third_party/JSON/JSON-2.59/t/e05_esc_slash.t » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698