Data-AnyXfer
view release on metacpan or search on metacpan
t/json/upstream/12_blessed.t view on Meta::CPAN
sub ok($;$) {
print $_[0] ? "" : "not ", "ok ", ++$test, "\n";
}
my $o1 = bless { a => 3 }, "XX";
my $o2 = bless \(my $dummy = 1), "YY";
if (eval 'require Hash::Util') {
if ($Hash::Util::VERSION > 0.05) {
Hash::Util::lock_ref_keys($o1);
print "# blessed hash is locked\n";
}
else {
Hash::Util::lock_hash($o1);
print "# hash is locked\n";
}
}
else {
print "# locked hashes are not supported\n";
};
sub XX::TO_JSON {
{__,""}
}
my $js = Data::AnyXfer::JSON->new;
eval { $js->encode ($o1) }; ok ($@ =~ /allow_blessed/);
eval { $js->encode ($o2) }; ok ($@ =~ /allow_blessed/);
( run in 0.734 second using v1.01-cache-2.11-cpan-49f99fa48dc )