diff options
Diffstat (limited to 'cpan/JSON-PP/t/115_tie_ixhash.t')
-rw-r--r-- | cpan/JSON-PP/t/115_tie_ixhash.t | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/cpan/JSON-PP/t/115_tie_ixhash.t b/cpan/JSON-PP/t/115_tie_ixhash.t new file mode 100644 index 0000000000..51b3a4f79b --- /dev/null +++ b/cpan/JSON-PP/t/115_tie_ixhash.t @@ -0,0 +1,46 @@ + +use strict; +use Test::More; +BEGIN { plan tests => 2 }; + +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } + +use JSON::PP; + +# from https://rt.cpan.org/Ticket/Display.html?id=25162 + +SKIP: { + eval {require Tie::IxHash}; + skip "Can't load Tie::IxHash.", 2 if ($@); + + my %columns; + tie %columns, 'Tie::IxHash'; + + %columns = ( + id => 'int', + 1 => 'a', + 2 => 'b', + 3 => 'c', + 4 => 'd', + 5 => 'e', + ); + + my $json = JSON::PP->new; + + my $js = $json->encode(\%columns); + is( $js, q/{"id":"int","1":"a","2":"b","3":"c","4":"d","5":"e"}/ ); + + $js = $json->pretty->encode(\%columns); + is( $js, <<'STR' ); +{ + "id" : "int", + "1" : "a", + "2" : "b", + "3" : "c", + "4" : "d", + "5" : "e" +} +STR + +} + |