| 1 |
# https://rt.cpan.org/Public/Bug/Display.html?id=52847 |
| 2 |
|
| 3 |
use strict; |
| 4 |
use Test::More; |
| 5 |
|
| 6 |
BEGIN { plan tests => 2 }; |
| 7 |
BEGIN { $ENV{PERL_JSON_BACKEND} ||= 1; } |
| 8 |
|
| 9 |
use JSON -support_by_pp; |
| 10 |
|
| 11 |
SKIP: { |
| 12 |
skip "can't use JSON::XS.", 2, unless( JSON->backend->is_xs ); |
| 13 |
|
| 14 |
my $json = JSON->new->allow_barekey; |
| 15 |
|
| 16 |
for (1..2) { |
| 17 |
is_deeply( test($json, q!{foo:"foo"}! ), {foo=>'foo'} ); |
| 18 |
JSON->new->allow_singlequote(0); |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
sub test { |
| 24 |
my ($coder, $str) = @_; |
| 25 |
my $rv; |
| 26 |
return $rv if eval { $rv = $coder->decode($str); 1 }; |
| 27 |
chomp( my $e = $@ ); |
| 28 |
return "died with \"$e\""; |
| 29 |
}; |
| 30 |
|
| 31 |
|
| 32 |
|