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)";
19 Usage: Internals::SvREADONLY(SCALAR[, ON]) at (eval 1) line 1.
20 Usage: Internals::SvREFCNT(SCALAR[, REFCOUNT]) at (eval 2) line 1.
21 Usage: Internals::hv_clear_placeholders(hv) at (eval 3) line 1.
25 # Various conundrums with SvREADONLY
28 Internals::SvREADONLY $x, 1;
29 ok Internals::SvREADONLY($x),
30 'read-only glob copies are read-only acc. to Internals::';
32 like $@, qr/Modification of a read-only value attempted at/,
33 'read-only glob copies';
34 Internals::SvREADONLY($x,0);
36 is $x, 42, 'Internals::SvREADONLY can turn off readonliness on globs';
38 # Same thing with regexps
40 Internals::SvREADONLY $x, 1;
41 ok Internals::SvREADONLY($x),
42 'read-only regexps are read-only acc. to Internals::';
44 like $@, qr/Modification of a read-only value attempted at/,
46 Internals::SvREADONLY($x,0);
48 is $x, 42, 'Internals::SvREADONLY can turn off readonliness on regexps';
51 Internals::SvREADONLY $h{a}, 1;
53 like $@, qr/Modification of a read-only value attempted at/,
54 'making a COW scalar into a read-only one';
57 ok !Internals::SvREADONLY($h{b}),
58 'cows are not read-only acc. to Internals::';
59 Internals::SvREADONLY($h{b},0);
61 is __PACKAGE__, 'main',
62 'turning off a cow’s readonliness did not affect sharers of the same PV';