use strict qw(refs subs);
-plan(228);
+plan(235);
# Test glob operations.
&$subref;
is ($called, 1);
}
+is ref eval {\&{""}}, "CODE", 'reference to &{""} [perl #94476]';
# Test references to return values of operators (TARGs/PADTMPs)
{
'DESTROY called on closure variable'
);
+# But cursing objects must not result in double frees
+# This caused "Attempt to free unreferenced scalar" in 5.16.
+fresh_perl_is(
+ 'bless \%foo::, bar::; bless \%bar::, foo::; print "ok\n"', "ok\n",
+ { stderr => 1 },
+ 'no double free when stashes are blessed into each other');
+
# test if refgen behaves with autoviv magic
{
{
local $@;
eval { ()[0]{foo} };
- like ( "$@", "Can't use an undefined value as a HASH reference",
+ like ( "$@", qr/Can't use an undefined value as a HASH reference/,
"deref of undef from list slice fails" );
}
is ref( bless {}, "nul\0clean" ), "nul\0clean", "ref() is nul-clean";
+# Test constants and references thereto.
+for (3) {
+ eval { $_ = 4 };
+ like $@, qr/^Modification of a read-only/,
+ 'assignment to value aliased to literal number';
+ require Config;
+ eval { ${\$_} = 4 };
+ like $@, qr/^Modification of a read-only/,
+ 'refgen does not allow assignment to value aliased to literal number';
+}
+for ("4eounthouonth") {
+ eval { $_ = 4 };
+ like $@, qr/^Modification of a read-only/,
+ 'assignment to value aliased to literal string';
+ require Config;
+ eval { ${\$_} = 4 };
+ like $@, qr/^Modification of a read-only/,
+ 'refgen does not allow assignment to value aliased to literal string';
+}
+{
+ my $aref = \123;
+ is \$$aref, $aref,
+ '[perl #109746] referential identity of \literal under threads+mad'
+}
+
# Bit of a hack to make test.pl happy. There are 3 more tests after it leaves.
$test = curr_test();
curr_test($test + 3);