diff options
Diffstat (limited to 't')
41 files changed, 72 insertions, 18 deletions
diff --git a/t/00_load.t b/t/00_load.t index 4409ce1..3727faf 100644 --- a/t/00_load.t +++ b/t/00_load.t @@ -1,5 +1,9 @@ # copied over from JSON::XS and modified to use JSON +use strict; +use warnings; + +my $loaded; BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } diff --git a/t/01_utf8.t b/t/01_utf8.t index dccefa5..b05ba66 100644 --- a/t/01_utf8.t +++ b/t/01_utf8.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 9 }; diff --git a/t/02_error.t b/t/02_error.t index a362302..2c034bb 100644 --- a/t/02_error.t +++ b/t/02_error.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 35 }; diff --git a/t/03_types.t b/t/03_types.t index 1d98332..1037a7c 100644 --- a/t/03_types.t +++ b/t/03_types.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 76 + 2 }; diff --git a/t/04_dwiw_encode.t b/t/04_dwiw_encode.t index 14a30dd..b31cedd 100644 --- a/t/04_dwiw_encode.t +++ b/t/04_dwiw_encode.t @@ -6,6 +6,7 @@ # Authors: don use strict; +use warnings; use Test; # main diff --git a/t/06_pc_pretty.t b/t/06_pc_pretty.t index 333cc7a..a162b7d 100644 --- a/t/06_pc_pretty.t +++ b/t/06_pc_pretty.t @@ -2,6 +2,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 9 }; @@ -10,7 +11,7 @@ BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } use JSON; my ($js,$obj,$json); -my $pc = new JSON; +my $pc = JSON->new; $obj = {foo => "bar"}; $js = $pc->encode($obj); diff --git a/t/07_pc_esc.t b/t/07_pc_esc.t index 1bb080c..7fa3f8d 100644 --- a/t/07_pc_esc.t +++ b/t/07_pc_esc.t @@ -7,6 +7,7 @@ use Test::More; use strict; +use warnings; use utf8; BEGIN { plan tests => 17 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } @@ -16,7 +17,7 @@ use JSON; ######################### my ($js,$obj,$str); -my $pc = new JSON; +my $pc = JSON->new; $obj = {test => qq|abc"def|}; $str = $pc->encode($obj); diff --git a/t/08_pc_base.t b/t/08_pc_base.t index f483ed2..1607569 100644 --- a/t/08_pc_base.t +++ b/t/08_pc_base.t @@ -4,6 +4,7 @@ use Test::More; # copied over from JSON::XS and modified to use JSON use strict; +use warnings; BEGIN { plan tests => 20 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } @@ -11,7 +12,7 @@ use JSON; my ($js,$obj); -my $pc = new JSON; +my $pc = JSON->new; $js = q|{}|; diff --git a/t/09_pc_extra_number.t b/t/09_pc_extra_number.t index 697786a..7d1748f 100644 --- a/t/09_pc_extra_number.t +++ b/t/09_pc_extra_number.t @@ -3,6 +3,7 @@ use Test::More; use strict; +use warnings; BEGIN { plan tests => 6 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } @@ -11,7 +12,7 @@ use utf8; ######################### my ($js,$obj); -my $pc = new JSON; +my $pc = JSON->new; $js = '{"foo":0}'; $obj = $pc->decode($js); diff --git a/t/104_sortby.t b/t/104_sortby.t index 20b087e..9262381 100644 --- a/t/104_sortby.t +++ b/t/104_sortby.t @@ -1,6 +1,7 @@ use Test::More; use strict; +use warnings; BEGIN { plan tests => 3 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } use JSON -support_by_pp; diff --git a/t/105_esc_slash.t b/t/105_esc_slash.t index 495766e..3aad042 100644 --- a/t/105_esc_slash.t +++ b/t/105_esc_slash.t @@ -1,6 +1,7 @@ use Test::More;
-use strict;
+use strict; +use warnings;
BEGIN { plan tests => 2 };
BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
use JSON -support_by_pp;
diff --git a/t/106_allow_barekey.t b/t/106_allow_barekey.t index 042e0bd..1305c7f 100644 --- a/t/106_allow_barekey.t +++ b/t/106_allow_barekey.t @@ -1,6 +1,7 @@ use Test::More;
-use strict;
+use strict; +use warnings;
BEGIN { plan tests => 2 };
BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
use JSON -support_by_pp;
diff --git a/t/107_allow_singlequote.t b/t/107_allow_singlequote.t index b1f6a6c..c7bec6c 100644 --- a/t/107_allow_singlequote.t +++ b/t/107_allow_singlequote.t @@ -1,6 +1,7 @@ use Test::More;
use strict;
+use warnings;
BEGIN { plan tests => 4 };
BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
use JSON -support_by_pp;
diff --git a/t/108_decode.t b/t/108_decode.t index 7e1e547..e38e438 100644 --- a/t/108_decode.t +++ b/t/108_decode.t @@ -2,6 +2,7 @@ # decode on Perl 5.005, 5.6, 5.8 or later # use strict; +use warnings; use Test::More; BEGIN { plan tests => 6 }; diff --git a/t/109_encode.t b/t/109_encode.t index c189297..afc5fe3 100644 --- a/t/109_encode.t +++ b/t/109_encode.t @@ -2,6 +2,7 @@ # decode on Perl 5.005, 5.6, 5.8 or later # use strict; +use warnings; use Test::More; BEGIN { plan tests => 7 }; diff --git a/t/10_pc_keysort.t b/t/10_pc_keysort.t index 5dc42ac..218b0bb 100644 --- a/t/10_pc_keysort.t +++ b/t/10_pc_keysort.t @@ -3,6 +3,7 @@ use Test::More; use strict; +use warnings; BEGIN { plan tests => 1 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } diff --git a/t/110_bignum.t b/t/110_bignum.t index 044e0e6..2425131 100644 --- a/t/110_bignum.t +++ b/t/110_bignum.t @@ -1,5 +1,6 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 9 }; @@ -20,7 +21,7 @@ my $fix = !$v ? '+' : ''; -my $json = new JSON; +my $json = JSON->new; $json->allow_nonref->allow_bignum(1); $json->convert_blessed->allow_blessed; diff --git a/t/112_upgrade.t b/t/112_upgrade.t index 94b6d1f..6b9ad89 100644 --- a/t/112_upgrade.t +++ b/t/112_upgrade.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 3 }; diff --git a/t/113_overloaded_eq.t b/t/113_overloaded_eq.t index f9bc8e8..0aaa7d0 100644 --- a/t/113_overloaded_eq.t +++ b/t/113_overloaded_eq.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More tests => 4; BEGIN { @@ -28,6 +29,7 @@ ok(!$@); package Foo; use strict; +use warnings; use overload ( 'eq' => sub { 0 }, '""' => sub { $_[0] }, @@ -41,6 +43,7 @@ sub TO_JSON { package Bar; use strict; +use warnings; use overload ( 'eq' => sub { 0 }, '""' => sub { $_[0] }, diff --git a/t/114_decode_prefix.t b/t/114_decode_prefix.t index 78db21e..91ec3e0 100644 --- a/t/114_decode_prefix.t +++ b/t/114_decode_prefix.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More tests => 8; BEGIN { diff --git a/t/115_tie_ixhash.t b/t/115_tie_ixhash.t index 95920e0..e03d0c7 100644 --- a/t/115_tie_ixhash.t +++ b/t/115_tie_ixhash.t @@ -1,5 +1,6 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 2 }; diff --git a/t/116_incr_parse_fixed.t b/t/116_incr_parse_fixed.t index 7bbee2f..aefdcb8 100644 --- a/t/116_incr_parse_fixed.t +++ b/t/116_incr_parse_fixed.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More tests => 4; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } diff --git a/t/117_numbers.t b/t/117_numbers.t index 6eed93d..f7e99fb 100644 --- a/t/117_numbers.t +++ b/t/117_numbers.t @@ -1,5 +1,6 @@ use Test::More; use strict; +use warnings; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } BEGIN { $ENV{PERL_JSON_PP_USE_B} = 0 } use JSON; diff --git a/t/118_boolean_values.t b/t/118_boolean_values.t index 32e7390..732e469 100644 --- a/t/118_boolean_values.t +++ b/t/118_boolean_values.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } use JSON; @@ -38,13 +39,14 @@ if (eval "require Types::Serialiser; 1") { push @tests, [Types::Serialiser::true(), Types::Serialiser::false(), 'Types::Serialiser::BooleanBase', 'Types::Serialiser::BooleanBase']; } -plan tests => 13 * @tests; +plan tests => 15 * @tests; my $json = JSON->new; for my $test (@tests) { my ($true, $false, $true_class, $false_class, $incompat) = @$test; - $json->boolean_values($false, $true); + my $ret = $json->boolean_values($false, $true); + is $ret => $json, "returns the same object"; my ($new_false, $new_true) = $json->get_boolean_values; ok defined $new_true, "new true class is defined"; ok defined $new_false, "new false class is defined"; @@ -71,7 +73,8 @@ for my $test (@tests) { is $should_false_json => 'false', "A $false_class object turns into JSON false"; } - $json->boolean_values(); + $ret = $json->boolean_values(); + is $ret => $json, "returns the same object"; ok !$json->get_boolean_values, "reset boolean values"; $should_true = $json->allow_nonref(1)->decode('true'); diff --git a/t/11_pc_expo.t b/t/11_pc_expo.t index 585290a..7d780ca 100644 --- a/t/11_pc_expo.t +++ b/t/11_pc_expo.t @@ -3,6 +3,7 @@ use Test::More; use strict; +use warnings; BEGIN { plan tests => 8 + 2 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } @@ -10,7 +11,7 @@ use JSON; ######################### my ($js,$obj); -my $pc = new JSON; +my $pc = JSON->new; $js = q|[-12.34]|; $obj = $pc->decode($js); diff --git a/t/12_blessed.t b/t/12_blessed.t index f966f43..c8800dd 100644 --- a/t/12_blessed.t +++ b/t/12_blessed.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 16 }; diff --git a/t/13_limit.t b/t/13_limit.t index 6493733..2a53882 100644 --- a/t/13_limit.t +++ b/t/13_limit.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 11 }; diff --git a/t/14_latin1.t b/t/14_latin1.t index ceda9db..c88cbba 100644 --- a/t/14_latin1.t +++ b/t/14_latin1.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 4 }; diff --git a/t/15_prefix.t b/t/15_prefix.t index a9c5b2e..02a5cb1 100644 --- a/t/15_prefix.t +++ b/t/15_prefix.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 4 }; diff --git a/t/16_tied.t b/t/16_tied.t index 2298d7d..7d3594a 100644 --- a/t/16_tied.t +++ b/t/16_tied.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 2 }; diff --git a/t/17_relaxed.t b/t/17_relaxed.t index 01cf81c..f4421da 100644 --- a/t/17_relaxed.t +++ b/t/17_relaxed.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 8 }; diff --git a/t/19_incr.t b/t/19_incr.t index 6749fd4..4610781 100644 --- a/t/19_incr.t +++ b/t/19_incr.t @@ -45,7 +45,7 @@ splitter +JSON->new->allow_nonref (1), ' 0.00E+00 '; { my $text = '[5],{"":1} , [ 1,2, 3], {"3":null}'; - my $coder = new JSON; + my $coder = JSON->new; for (0 .. length $text) { my $a = substr $text, 0, $_; my $b = substr $text, $_; @@ -69,7 +69,7 @@ splitter +JSON->new->allow_nonref (1), ' 0.00E+00 '; { my $text = '[x][5]'; - my $coder = new JSON; + my $coder = JSON->new; $coder->incr_parse ($text); ok (!eval { $coder->incr_parse }, "sparse1"); ok (!eval { $coder->incr_parse }, "sparse2"); diff --git a/t/20_unknown.t b/t/20_unknown.t index 921acae..434cc1a 100644 --- a/t/20_unknown.t +++ b/t/20_unknown.t @@ -1,11 +1,10 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 10 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } - -use strict; use JSON; my $json = JSON->new; diff --git a/t/21_evans.t b/t/21_evans.t index 9136791..d907ed9 100644 --- a/t/21_evans.t +++ b/t/21_evans.t @@ -14,7 +14,7 @@ print "1..1\n"; my $data = ["\x{53f0}\x{6240}\x{306e}\x{6d41}\x{3057}", "\x{6c60}\x{306e}\x{30ab}\x{30a8}\x{30eb}"]; my $js = JSON->new->encode ($data); -my $j = new JSON; +my $j = JSON->new; my $object = $j->incr_parse ($js); die "no object" if !$object; diff --git a/t/52_object.t b/t/52_object.t index 1acf5ea..212f741 100644 --- a/t/52_object.t +++ b/t/52_object.t @@ -1,6 +1,17 @@ # copied over from JSON::XS and modified to use JSON +package JSON::freeze; + +1; + +package JSON::tojson; + +1; + +package main; + use strict; +use warnings; use Test::More; BEGIN { $^W = 0 } # hate @@ -52,8 +63,8 @@ sub JSON::freeze::THAW { 777 } -my $obj = bless { k => 1 }, JSON::freeze::; -my $enc = $json->encode ($obj); +$obj = bless { k => 1 }, JSON::freeze::; +$enc = $json->encode ($obj); ok ($enc eq '("JSON::freeze")[3,1,2]'); my $dec = $json->decode ($enc); diff --git a/t/99_binary.t b/t/99_binary.t index 3c19c35..8779643 100644 --- a/t/99_binary.t +++ b/t/99_binary.t @@ -1,6 +1,7 @@ # copied over from JSON::XS and modified to use JSON use strict; +use warnings; use Test::More; BEGIN { plan tests => 24576 }; diff --git a/t/gh_28_json_test_suite.t b/t/gh_28_json_test_suite.t index a8f7401..4146d50 100644 --- a/t/gh_28_json_test_suite.t +++ b/t/gh_28_json_test_suite.t @@ -2,6 +2,7 @@ # by Nicolas Seriot (https://github.com/nst/JSONTestSuite) use strict; +use warnings; use Test::More; BEGIN { plan skip_all => 'this test is for Perl 5.8 or later' if $] < 5.008; } diff --git a/t/gh_29_trailing_false_value.t b/t/gh_29_trailing_false_value.t index 5a42bb1..44636ee 100644 --- a/t/gh_29_trailing_false_value.t +++ b/t/gh_29_trailing_false_value.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 1 }; diff --git a/t/rt_116998_wrong_character_offset.t b/t/rt_116998_wrong_character_offset.t index 8b9c0c5..30522ba 100644 --- a/t/rt_116998_wrong_character_offset.t +++ b/t/rt_116998_wrong_character_offset.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 4 }; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } diff --git a/t/rt_90071_incr_parse.t b/t/rt_90071_incr_parse.t index c45de15..10015d1 100644 --- a/t/rt_90071_incr_parse.t +++ b/t/rt_90071_incr_parse.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More; BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; } use JSON; diff --git a/t/zero-mojibake.t b/t/zero-mojibake.t index 72c48f8..bafb453 100644 --- a/t/zero-mojibake.t +++ b/t/zero-mojibake.t @@ -1,4 +1,5 @@ use strict; +use warnings; use Test::More; BEGIN { plan tests => 1 }; |