File: 53_readonly.t

package info (click to toggle)
libcpanel-json-xs-perl 4.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,872 kB
  • sloc: perl: 1,165; makefile: 8
file content (20 lines) | stat: -rw-r--r-- 405 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!perl
use strict;
use warnings;
use Test::More $] < 5.008 ? (skip_all => "5.6") : (tests => 1);
use Cpanel::JSON::XS;

my $json = Cpanel::JSON::XS->new->convert_blessed;

sub Foo::TO_JSON {
    return 1;
}

my $string = "something";
my $object = \$string;
bless $object,'Foo';
Internals::SvREADONLY($string,1);
my $hash = {obj=>$object};

my $enc = $json->encode ($hash);
ok $enc eq '{"obj":1}', "$enc";