OLD | NEW |
(Empty) | |
| 1 |
| 2 use strict; |
| 3 use Test::More tests => 8; |
| 4 |
| 5 BEGIN { |
| 6 $ENV{ PERL_JSON_BACKEND } = "JSON::backportPP"; |
| 7 } |
| 8 |
| 9 use JSON; |
| 10 |
| 11 my $json = JSON->new; |
| 12 |
| 13 my $complete_text = qq/{"foo":"bar"}/; |
| 14 my $garbaged_text = qq/{"foo":"bar"}\n/; |
| 15 my $garbaged_text2 = qq/{"foo":"bar"}\n\n/; |
| 16 my $garbaged_text3 = qq/{"foo":"bar"}\n----/; |
| 17 |
| 18 is( ( $json->decode_prefix( $complete_text ) ) [1], 13 ); |
| 19 is( ( $json->decode_prefix( $garbaged_text ) ) [1], 13 ); |
| 20 is( ( $json->decode_prefix( $garbaged_text2 ) ) [1], 13 ); |
| 21 is( ( $json->decode_prefix( $garbaged_text3 ) ) [1], 13 ); |
| 22 |
| 23 eval { $json->decode( "\n" ) }; ok( $@ =~ /malformed JSON/ ); |
| 24 eval { $json->decode('null') }; ok $@ =~ /allow_nonref/; |
| 25 |
| 26 eval { $json->decode_prefix( "\n" ) }; ok( $@ =~ /malformed JSON/ ); |
| 27 eval { $json->decode_prefix('null') }; ok $@ =~ /allow_nonref/; |
| 28 |
OLD | NEW |