diff options
Diffstat (limited to 'gnu/usr.bin/perl/cpan/JSON-PP/t/001_utf8.t')
-rw-r--r-- | gnu/usr.bin/perl/cpan/JSON-PP/t/001_utf8.t | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/001_utf8.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/001_utf8.t index e160f824161..4044e44690f 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/001_utf8.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/001_utf8.t @@ -10,17 +10,23 @@ BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } use utf8; use JSON::PP; - -ok (JSON::PP->new->allow_nonref (1)->utf8 (1)->encode ("ü") eq "\"\xc3\xbc\""); -ok (JSON::PP->new->allow_nonref (1)->encode ("ü") eq "\"ü\""); -ok (JSON::PP->new->allow_nonref (1)->ascii (1)->utf8 (1)->encode (chr 0x8000) eq '"\u8000"'); -ok (JSON::PP->new->allow_nonref (1)->ascii (1)->utf8 (1)->pretty (1)->encode (chr 0x10402) eq "\"\\ud801\\udc02\"\n"); - -eval { JSON::PP->new->allow_nonref (1)->utf8 (1)->decode ('"ü"') }; +my $pilcrow_utf8 = (ord "^" == 0x5E) ? "\xc2\xb6" # 8859-1 + : (ord "^" == 0x5F) ? "\x80\x65" # CP 1024 + : "\x78\x64"; # assume CP 037 +is (JSON::PP->new->allow_nonref (1)->utf8 (1)->encode ("¶"), "\"$pilcrow_utf8\""); +is (JSON::PP->new->allow_nonref (1)->encode ("¶"), "\"¶\""); +is (JSON::PP->new->allow_nonref (1)->ascii (1)->utf8 (1)->encode (chr 0x8000), '"\u8000"'); +is (JSON::PP->new->allow_nonref (1)->ascii (1)->utf8 (1)->pretty (1)->encode (chr 0x10402), "\"\\ud801\\udc02\"\n"); + +eval { JSON::PP->new->allow_nonref (1)->utf8 (1)->decode ('"¶"') }; ok $@ =~ /malformed UTF-8/; -ok (JSON::PP->new->allow_nonref (1)->decode ('"ü"') eq "ü"); -ok (JSON::PP->new->allow_nonref (1)->decode ('"\u00fc"') eq "ü"); -ok (JSON::PP->new->allow_nonref (1)->decode ('"\ud801\udc02' . "\x{10204}\"") eq "\x{10402}\x{10204}"); -ok (JSON::PP->new->allow_nonref (1)->decode ('"\"\n\\\\\r\t\f\b"') eq "\"\012\\\015\011\014\010"); +is (JSON::PP->new->allow_nonref (1)->decode ('"¶"'), "¶"); +is (JSON::PP->new->allow_nonref (1)->decode ('"\u00b6"'), "¶"); +is (JSON::PP->new->allow_nonref (1)->decode ('"\ud801\udc02' . "\x{10204}\""), "\x{10402}\x{10204}"); + +my $controls = (ord "^" == 0x5E) ? "\012\\\015\011\014\010" + : (ord "^" == 0x5F) ? "\025\\\015\005\014\026" # CP 1024 + : "\045\\\015\005\014\026"; # assume CP 037 +is (JSON::PP->new->allow_nonref (1)->decode ('"\"\n\\\\\r\t\f\b"'), "\"$controls"); |