This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[Merge] Constants, inlined subs, TARGs, ...
[perl5.git] / cpan / JSON-PP / t / 112_upgrade.t
CommitLineData
d5424315
DG
1use strict;
2use Test::More;
3
4BEGIN { plan tests => 3 };
5
6BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
7
8use JSON::PP;
9
10BEGIN {
11 use lib qw(t);
12 use _unicode_handling;
13}
14
15my $json = JSON::PP->new->allow_nonref->utf8;
16my $str = '\\u00c8';
17
18my $value = $json->decode( '"\\u00c8"' );
19
20#use Devel::Peek;
21#Dump( $value );
22
23is( $value, chr 0xc8 );
24
25SKIP: {
26 skip "UNICODE handling is disabale.", 1 unless $JSON::PP::can_handle_UTF16_and_utf8;
27 ok( utf8::is_utf8( $value ) );
28}
29
30eval { $json->decode( '"' . chr(0xc8) . '"' ) };
31ok( $@ =~ /malformed UTF-8 character in JSON string/ );
32