t/106_allow_barekey.t
raw| 1 | |
| 2 | use Test::More; |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | BEGIN { plan tests => 2 }; |
| 6 | BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } |
| 7 | use JSON -support_by_pp; |
| 8 | ######################### |
| 9 | |
| 10 | my $json = JSON->new->allow_nonref; |
| 11 | |
| 12 | eval q| $json->decode('{foo:"bar"}') |; |
| 13 | |
| 14 | ok($@); # in XS and PP, the error message differs. |
| 15 | |
| 16 | $json->allow_barekey; |
| 17 | |
| 18 | is($json->decode('{foo:"bar"}')->{foo}, 'bar'); |
| 19 | |
| 20 |