diff options
author | Andrew Fresh <afresh1@cvs.openbsd.org> | 2019-02-13 21:11:45 +0000 |
---|---|---|
committer | Andrew Fresh <afresh1@cvs.openbsd.org> | 2019-02-13 21:11:45 +0000 |
commit | 0cc2c999dde616622e1c1a39da60828645040e47 (patch) | |
tree | d67af193288a2d010b2eae5d526d615c6adbcaf5 /gnu/usr.bin/perl/cpan/JSON-PP | |
parent | 2e70a883f7ff179f56cb433b7b3473e5ca1eefe4 (diff) |
Import perl-5.28.1
looking good sthen@, Great! bluhm@
Diffstat (limited to 'gnu/usr.bin/perl/cpan/JSON-PP')
30 files changed, 235 insertions, 63 deletions
diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/lib/JSON/PP/Boolean.pm b/gnu/usr.bin/perl/cpan/JSON-PP/lib/JSON/PP/Boolean.pm index 0b1fb19b2c2..1d1c5c485cc 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/lib/JSON/PP/Boolean.pm +++ b/gnu/usr.bin/perl/cpan/JSON-PP/lib/JSON/PP/Boolean.pm @@ -1,3 +1,19 @@ +package JSON::PP::Boolean; + +use strict; +use overload ( + "0+" => sub { ${$_[0]} }, + "++" => sub { $_[0] = ${$_[0]} + 1 }, + "--" => sub { $_[0] = ${$_[0]} - 1 }, + fallback => 1, +); + +$JSON::PP::Boolean::VERSION = '2.97001'; + +1; + +__END__ + =head1 NAME JSON::PP::Boolean - dummy module providing JSON::PP::Boolean @@ -11,13 +27,6 @@ JSON::PP::Boolean - dummy module providing JSON::PP::Boolean This module exists only to provide overload resolution for Storable and similar modules. See L<JSON::PP> for more info about this class. -=cut - -use JSON::PP (); -use strict; - -1; - =head1 AUTHOR This idea is from L<JSON::XS::Boolean> written by Marc Lehmann <schmorp[at]schmorp.de> 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 65c7d333ee3..e78fdcb11fb 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 @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; use Test::More; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/002_error.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/002_error.t index ec42d506984..166bafc3677 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/002_error.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/002_error.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; use Test::More; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/003_types.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/003_types.t index eaf114bcdcb..22e0f7ec2e0 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/003_types.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/003_types.t @@ -1,8 +1,8 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; use Test::More; -BEGIN { plan tests => 76 }; +BEGIN { plan tests => 78 }; BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } @@ -21,6 +21,8 @@ ok ($false == !$true); ok (JSON::PP::is_bool $false); ok (++$false == 1); ok (!JSON::PP::is_bool $false); +ok (!JSON::PP::is_bool "JSON::PP::Boolean"); +ok (!JSON::PP::is_bool {}); # GH-34 ok (JSON::PP->new->allow_nonref (1)->decode ('5') == 5); ok (JSON::PP->new->allow_nonref (1)->decode ('-5') == -5); diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/006_pc_pretty.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/006_pc_pretty.t index b16bed68fdf..2de5c5d37cb 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/006_pc_pretty.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/006_pc_pretty.t @@ -1,7 +1,5 @@ -#! perl - -# copied over from JSON::PP::PC and modified to use JSON::PP -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::PC and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; use Test::More; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/007_pc_esc.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/007_pc_esc.t index 980e3a0b032..a5efc8beceb 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/007_pc_esc.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/007_pc_esc.t @@ -2,13 +2,13 @@ # このファイルのエンコーディングはUTF-8 # -# copied over from JSON::PP::PC and modified to use JSON::PP -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::PC and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; -BEGIN { plan tests => 17 }; +BEGIN { plan tests => 18 }; BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } @@ -91,3 +91,7 @@ is($obj->{id},"abc\\ndef",q|{"id":"abc\\\ndef"}|); $obj = $pc->decode(q|{"id":"abc\\\\\ndef"}|); is($obj->{id},"abc\\\ndef",q|{"id":"abc\\\\\ndef"}|); +$obj = {test => "\'I said\', \"She said\""}; +$str = $pc->encode($obj); +is($str,q|{"test":"'I said', \"She said\""}|); + diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/008_pc_base.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/008_pc_base.t index 371e62a81fd..bcc9d8e7bd2 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/008_pc_base.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/008_pc_base.t @@ -1,7 +1,7 @@ use Test::More; -# copied over from JSON::PP::PC and modified to use JSON::PP -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::PC and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; BEGIN { plan tests => 20 }; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/009_pc_extra_number.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/009_pc_extra_number.t index 4357939c2dd..25497a6ff87 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/009_pc_extra_number.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/009_pc_extra_number.t @@ -1,5 +1,5 @@ -# copied over from JSON::PP::PC and modified to use JSON::PP -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::PC and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/010_pc_keysort.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/010_pc_keysort.t index faebaf78259..c5e5c099a4a 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/010_pc_keysort.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/010_pc_keysort.t @@ -1,5 +1,5 @@ -# copied over from JSON::PP::PC and modified to use JSON::PP -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::PC and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/011_pc_expo.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/011_pc_expo.t index 766a8fb8d2e..154a8256ef4 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/011_pc_expo.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/011_pc_expo.t @@ -1,5 +1,5 @@ -# copied over from JSON::PP::PC and modified to use JSON::PP -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::PC and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; @@ -22,8 +22,10 @@ is($js,'[-12.34]', 'digit -12.34'); $js = q|[-1.234e5]|; $obj = $pc->decode($js); is($obj->[0], -123400, 'digit -1.234e5'); +{ #SKIP_IF_CPANEL $js = $pc->encode($obj); is($js,'[-123400]', 'digit -1.234e5'); +} $js = q|[1.23E-4]|; $obj = $pc->decode($js); @@ -38,10 +40,19 @@ else { } - -$js = q|[1.01e+67]|; # 30 -> 67 ... patched by H.Merijn Brand -$obj = $pc->decode($js); -is($obj->[0], 1.01e+67, 'digit 1.01e+67'); -$js = $pc->encode($obj); -like($js,qr/\[1.01[Ee]\+0?67\]/, 'digit 1.01e+67'); - +my $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/); + +if ($vax_float) { + # VAX has smaller float range. + $js = q|[1.01e+37]|; + $obj = $pc->decode($js); + is($obj->[0], eval '1.01e+37', 'digit 1.01e+37'); + $js = $pc->encode($obj); + like($js,qr/\[1.01[Ee]\+0?37\]/, 'digit 1.01e+37'); +} else { + $js = q|[1.01e+67]|; # 30 -> 67 ... patched by H.Merijn Brand + $obj = $pc->decode($js); + is($obj->[0], eval '1.01e+67', 'digit 1.01e+67'); + $js = $pc->encode($obj); + like($js,qr/\[1.01[Ee]\+0?67\]/, 'digit 1.01e+67'); +} diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/012_blessed.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/012_blessed.t index 06b4ba40392..7f0b41025c0 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/012_blessed.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/012_blessed.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; use Test::More; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/014_latin1.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/014_latin1.t index 2277b576225..6c02d627708 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/014_latin1.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/014_latin1.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/015_prefix.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/015_prefix.t index 74c96a7ac20..b6474fede65 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/015_prefix.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/015_prefix.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP BEGIN { $| = 1; print "1..4\n"; } BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/016_tied.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/016_tied.t index 27634158176..96035fea6c0 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/016_tied.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/016_tied.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; use Test::More; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/017_relaxed.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/017_relaxed.t index b577e33a74d..243f9973e45 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/017_relaxed.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/017_relaxed.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/018_json_checker.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/018_json_checker.t index c15781377ca..1e84987e6e6 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/018_json_checker.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/018_json_checker.t @@ -1,9 +1,7 @@ -#! perl - -# use the testsuite from http://www.json.org/JSON::PP_checker/ +# use the testsuite from http://www.json.org/JSON_checker/ # except for fail18.json, as we do not support a depth of 20 (but 16 and 32). -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; #no warnings; @@ -16,6 +14,8 @@ use JSON::PP; my $json = JSON::PP->new->utf8->max_depth(32)->canonical; +my $vax_float = (pack("d",1) =~ /^[\x80\x10]\x40/); + binmode DATA; my $num = 1; for (;;) { @@ -25,6 +25,9 @@ for (;;) { or last; $/ = "\n"; my $name = <DATA>; + if ($vax_float && $name =~ /pass1.json/) { + $test =~ s/\b23456789012E66\b/23456789012E20/; + } if (my $perl = eval { $json->decode ($test) }) { ok ($name =~ /^pass/, $name); #print $json->encode ($perl), "\n"; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/019_incr.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/019_incr.t index dc84c551060..9d4710bbd94 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/019_incr.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/019_incr.t @@ -1,6 +1,4 @@ -#!/usr/bin/perl -w - -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use strict; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/020_unknown.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/020_unknown.t index ef69338f43c..98e9528f7fe 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/020_unknown.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/020_unknown.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl -w - use strict; use Test::More; @@ -42,7 +40,7 @@ my $fh; open( $fh, '>hoge.txt' ) or die $!; eval q| $json->encode( [ $fh ] ) |; -ok( $@ =~ /encountered GLOB/, $@ ); +ok( $@ =~ /encountered GLOB|cannot encode reference to scalar/, $@ ); $json->allow_unknown(1); diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/021_evans_bugrep.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/021_evans_bugrep.t index e7d6dc5ed9f..ecbfcddc1d6 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/021_evans_bugrep.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/021_evans_bugrep.t @@ -32,7 +32,7 @@ eval { $j->incr_text; }; -like( $@, qr/incr_text can not be called when the incremental parser already started parsing/ ); +like( $@, qr/incr_text can ?not be called when the incremental parser already started parsing/ ); $object = $j->incr_parse($parts[1]); diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/099_binary.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/099_binary.t index 56f23297fa0..e924305e03d 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/099_binary.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/099_binary.t @@ -1,4 +1,4 @@ -# copied over from JSON::PP::XS and modified to use JSON::PP +# copied over from JSON::XS and modified to use JSON::PP use Test::More; use strict; @@ -40,7 +40,7 @@ sub test($) { ok ($_[0] eq JSON::PP->new->shrink->decode ($js)->[0]); } -srand 0; # doesn't help too much, but its at leats more deterministic +srand 0; # doesn't help too much, but its at least more deterministic #for (1..768) { for (1..64, 125..129, 255..257, 512, 704, 736, 768) { diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/108_decode.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/108_decode.t index 71c2ff5fadc..ae645e99a7c 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/108_decode.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/108_decode.t @@ -35,7 +35,7 @@ is($json->decode(q|"\u3042"|), $str); my $utf8 = $json->decode(q|"\ud808\udf45"|); # chr 12345 -utf8::encode($utf8); # UTf-8 flaged off +utf8::encode($utf8); # UTF-8 flagged off is($utf8, "\xf0\x92\x8d\x85"); diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/110_bignum.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/110_bignum.t index 9826c613030..c4c282f4370 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/110_bignum.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/110_bignum.t @@ -1,7 +1,7 @@ use strict; use Test::More; -BEGIN { plan tests => 6 }; +BEGIN { plan tests => 9 }; BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } @@ -10,7 +10,7 @@ use JSON::PP; eval q| require Math::BigInt |; SKIP: { - skip "Can't load Math::BigInt.", 6 if ($@); + skip "Can't load Math::BigInt.", 9 if ($@); my $v = Math::BigInt->VERSION; $v =~ s/_.+$// if $v; @@ -27,15 +27,24 @@ $json->convert_blessed->allow_blessed; my $num = $json->decode(q|100000000000000000000000000000000000000|); -isa_ok($num, 'Math::BigInt'); +ok($num->isa('Math::BigInt')); is("$num", $fix . '100000000000000000000000000000000000000'); is($json->encode($num), $fix . '100000000000000000000000000000000000000'); +{ #SKIP_UNLESS_PP 2.91_03, 2 +$num = $json->decode(q|10|); + +ok(!(ref $num and $num->isa('Math::BigInt')), 'small integer is not a BigInt'); +ok(!(ref $num and $num->isa('Math::BigFloat')), 'small integer is not a BigFloat'); +} + $num = $json->decode(q|2.0000000000000000001|); -isa_ok($num, 'Math::BigFloat'); +ok($num->isa('Math::BigFloat')); is("$num", '2.0000000000000000001'); is($json->encode($num), '2.0000000000000000001'); - +{ #SKIP_UNLESS_PP 2.90, 1 +is($json->encode([Math::BigInt->new("0")]), "[${fix}0]", "zero bigint is 0 (the number), not '0' (the string)" ); +} } diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/113_overloaded_eq.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/113_overloaded_eq.t index 7b56ab3e24f..1b61c48fb20 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/113_overloaded_eq.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/113_overloaded_eq.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use Test::More tests => 4; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/114_decode_prefix.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/114_decode_prefix.t index 70d842921fa..915ea1532e7 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/114_decode_prefix.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/114_decode_prefix.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use Test::More tests => 8; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/116_incr_parse_fixed.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/116_incr_parse_fixed.t index 73c2462bf35..36e84de7fab 100644 --- a/gnu/usr.bin/perl/cpan/JSON-PP/t/116_incr_parse_fixed.t +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/116_incr_parse_fixed.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use Test::More tests => 4; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/117_numbers.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/117_numbers.t new file mode 100644 index 00000000000..73b2a6c826c --- /dev/null +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/117_numbers.t @@ -0,0 +1,23 @@ +use Test::More; +use strict; +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } +use JSON::PP; + +#SKIP_ALL_UNLESS_PP 2.90 +#SKIP_ALL_IF_XS + +BEGIN { plan tests => 3 } + +# TODO ("inf"/"nan" representations are not portable) +# is encode_json([9**9**9]), '["inf"]'; +# is encode_json([-sin(9**9**9)]), '["nan"]'; + +my $num = 3; +my $str = "$num"; +is encode_json({test => [$num, $str]}), '{"test":[3,"3"]}'; +$num = 3.21; +$str = "$num"; +is encode_json({test => [$num, $str]}), '{"test":[3.21,"3.21"]}'; +$str = '0 but true'; +$num = 1 + $str; +is encode_json({test => [$num, $str]}), '{"test":[1,"0 but true"]}'; diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/gh_28_json_test_suite.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/gh_28_json_test_suite.t new file mode 100644 index 00000000000..be536603813 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/gh_28_json_test_suite.t @@ -0,0 +1,59 @@ +# the following test cases are taken from JSONTestSuite +# by Nicolas Seriot (https://github.com/nst/JSONTestSuite) + +use strict; +use Test::More; + +BEGIN { plan skip_all => 'this test is for Perl 5.8 or later' if $] < 5.008; } + +BEGIN { plan tests => 20 }; + +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } + +use JSON::PP; + +my $DECODER = JSON::PP->new->utf8->allow_nonref; + +# n_multidigit_number_then_00 +decode_should_fail(qq!123\x00!); + +# number_-01 +decode_should_fail(qq![-01]!); + +# number_neg_int_starting_with_zero +decode_should_fail(qq![-012]!); + +# n_object_trailing_comment +decode_should_fail(qq!{"a":"b"}/**/!); + +# n_object_trailing_comment_slash_open +decode_should_fail(qq!{"a":"b"}//!); + +# n_structure_null-byte-outside-sting +decode_should_fail(qq![\x00]!); + +# n_structure_object_with_comment +decode_should_fail(qq!{"a":/*comment*/"b"}!); + +# n_structure_whitespace_formfeed +decode_should_fail(qq![\0x0c]!); + +# y_string_utf16BE_no_BOM +decode_should_pass(qq!\x00[\x00"\x00\xE9\x00"\x00]!); + +# y_string_utf16LE_no_BOM +decode_should_pass(qq![\x00"\x00\xE9\x00"\x00]\x00!); + +sub decode_should_pass { + my $json = shift; + my $result = eval { $DECODER->decode($json); }; + ok !$@, $@ || ''; + ok defined $result; +} + +sub decode_should_fail { + my $json = shift; + my $result = eval { $DECODER->decode($json); }; + ok $@, $@ || ''; + ok !defined $result; +} diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/gh_29_trailing_false_value.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/gh_29_trailing_false_value.t new file mode 100644 index 00000000000..bb408e93375 --- /dev/null +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/gh_29_trailing_false_value.t @@ -0,0 +1,13 @@ +use strict; +use Test::More; + +BEGIN { plan tests => 1 }; + +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } + +use JSON::PP; + +{ #SKIP_UNLESS_PP 2.90,1 + eval { JSON::PP->new->decode('{}0') }; + ok $@; +} diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/rt_116998_wrong_character_offset.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/rt_116998_wrong_character_offset.t new file mode 100644 index 00000000000..b8f4707c73b --- /dev/null +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/rt_116998_wrong_character_offset.t @@ -0,0 +1,22 @@ +use strict; +use Test::More; +BEGIN { plan tests => 4 }; +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } +use JSON::PP; + +{ #SKIP_UNLESS_PP 2.90, 1 +eval { decode_json(qq({"foo":{"bar":42})) }; +like $@ => qr/offset 17/; # 16 +} + +eval { decode_json(qq(["foo",{"bar":42})) }; +like $@ => qr/offset 17/; + +{ #SKIP_UNLESS_PP 2.90, 1 +eval { decode_json(qq(["foo",{"bar":42}"])) }; +like $@ => qr/offset 17/; # 18 +} + +eval { decode_json(qq({"foo":{"bar":42}"})) }; +like $@ => qr/offset 17/; + diff --git a/gnu/usr.bin/perl/cpan/JSON-PP/t/rt_90071_incr_parse.t b/gnu/usr.bin/perl/cpan/JSON-PP/t/rt_90071_incr_parse.t new file mode 100644 index 00000000000..dc1fd45cf7b --- /dev/null +++ b/gnu/usr.bin/perl/cpan/JSON-PP/t/rt_90071_incr_parse.t @@ -0,0 +1,29 @@ +use strict; +use Test::More; +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } +use JSON::PP; + +#SKIP_ALL_UNLESS_PP 2.90 + +BEGIN { plan tests => 2 }; + +my $json = JSON::PP->new; +my $kb = 'a' x 1024; +my $hash = { map { $_ => $kb } (1..40) }; +my $data = join ( '', $json->encode($hash), $json->encode($hash) ); +my $size = length($data); +# note "Total size: [$size]"; +my $offset = 0; +while ($size) { + # note "Bytes left [$size]"; + my $incr = substr($data, $offset, 4096); + my $bytes = length($incr); + $size -= $bytes; + $offset += $bytes; + if ($bytes) { + $json->incr_parse($incr); + } + while( my $obj = $json->incr_parse ) { + ok "Got JSON object"; + } +} |