BEGIN {
our $JSON_Class = _choose_json_module();
- $JSON_Class->import(qw(encode_json decode_json));
+
+ if ($JSON_Class eq 'JSON::PP') {
+ $JSON_Class->import(qw(encode_json));
+ eval '#line ' . __LINE__ . ' "' . __FILE__ . '"' . q{
+ package JSON::PP;
+ sub JSON::MaybeXS::decode_json ($) {
+ &decode_json;
+ }
+ 1;
+ } or die $@;
+ }
+ else {
+ $JSON_Class->import(qw(encode_json decode_json));
+ }
}
our @EXPORT = qw(encode_json decode_json JSON);
'Correct encode_json function'
);
-is(
- \&decode_json, \&JSON::PP::decode_json,
- 'Correct encode_json function'
-);
+is prototype \&decode_json, '$',
+ 'decode_json has correct prototype';
+
+is_deeply decode_json '[]', [],
+ 'decode_json works as expected';
+
+eval { decode_json undef }; my $msg = ' at ' . __FILE__ . ' line ' . __LINE__;
+like $@, qr/\Q$msg\E/,
+ 'decode_json reports error at correct location';
require 't/lib/is_bool.pm';