3 # Test the Internal::* functions and other tibits in universal.c
12 for my $arg ('', 'q[]', qw( 1 undef )) {
13 fresh_perl_is(<<"----", <<'====', "Internals::* functions check their argument under func() AND &func() [perl #77776]");
14 sub tryit { eval shift or warn \$@ }
15 tryit "&Internals::SvREADONLY($arg)";
16 tryit "&Internals::SvREFCNT($arg)";
17 tryit "&Internals::hv_clear_placeholders($arg)";
18 tryit "&Internals::HvREHASH($arg)";
20 Usage: Internals::SvREADONLY(SCALAR[, ON]) at (eval 1) line 1.
21 Usage: Internals::SvREFCNT(SCALAR[, REFCOUNT]) at (eval 2) line 1.
22 Usage: Internals::hv_clear_placeholders(hv) at (eval 3) line 1.
23 Internals::HvREHASH $hashref at (eval 4) line 1.
27 # Various conundrums with SvREADONLY
30 Internals::SvREADONLY $x, 1;
31 ok Internals::SvREADONLY($x),
32 'read-only glob copies are read-only acc. to Internals::';
34 like $@, qr/Modification of a read-only value attempted at/,
35 'read-only glob copies';
36 Internals::SvREADONLY($x,0);
38 is $x, 42, 'Internals::SvREADONLY can turn off readonliness on globs';
41 Internals::SvREADONLY $h{a}, 1;
43 like $@, qr/Modification of a read-only value attempted at/,
44 'making a COW scalar into a read-only one';
47 ok !Internals::SvREADONLY($h{b}),
48 'cows are not read-only acc. to Internals::';
49 Internals::SvREADONLY($h{b},0);
51 is __PACKAGE__, 'main',
52 'turning off a cow’s readonliness did not affect sharers of the same PV';