| Index: third_party/JSON/JSON-2.59/t/e04_sortby.t
|
| diff --git a/third_party/JSON/JSON-2.59/t/e04_sortby.t b/third_party/JSON/JSON-2.59/t/e04_sortby.t
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..69bc08f528ce086d940a309085815d5b55d27e12
|
| --- /dev/null
|
| +++ b/third_party/JSON/JSON-2.59/t/e04_sortby.t
|
| @@ -0,0 +1,24 @@
|
| +
|
| +use Test::More;
|
| +use strict;
|
| +BEGIN { plan tests => 3 };
|
| +BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
|
| +use JSON;
|
| +#########################
|
| +
|
| +my ($js,$obj);
|
| +my $pc = JSON->new;
|
| +
|
| +$obj = {a=>1, b=>2, c=>3, d=>4, e=>5, f=>6, g=>7, h=>8, i=>9};
|
| +
|
| +$js = $pc->sort_by(1)->encode($obj);
|
| +is($js, q|{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9}|);
|
| +
|
| +
|
| +$js = $pc->sort_by(sub { $JSON::PP::a cmp $JSON::PP::b })->encode($obj);
|
| +is($js, q|{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9}|);
|
| +
|
| +$js = $pc->sort_by('hoge')->encode($obj);
|
| +is($js, q|{"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9}|);
|
| +
|
| +sub JSON::PP::hoge { $JSON::PP::a cmp $JSON::PP::b }
|
|
|