1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# This is a test for the fix of the following bug:
# https://github.com/benkasminbullock/JSON-Parse/issues/34
# There is also a discussion here:
# http://perlmonks.org/?node_id=1165399
use FindBin '$Bin';
use lib "$Bin";
use JPT;
my $j = JSON::Parse->new();
# no complain, no effect:
$j->warn_only(1);
# legal json:
eval {
my $pl = $j->run('{"k":"v"}');
};
ok (! $@);
# illegal json, the following statement dies:
my $warning;
$SIG{__WARN__} = sub { $warning = "@_" };
eval {
my $pl = $j->run('illegal json');
};
ok (! $@, "No fatal error");
ok ($warning, "Got warning");
undef $SIG{__WARN__};
done_testing ();
|