4 # various typeglob tests
17 # type coercion on assignment
21 is(ref(\$bar), 'SCALAR');
24 # type coercion (not) on misc ops
27 is(ref(\$foo), 'GLOB');
29 unlike ($foo, qr/abcd/);
30 is(ref(\$foo), 'GLOB');
32 is($foo, '*main::bar');
33 is(ref(\$foo), 'GLOB');
38 is(ref(\$foo), 'GLOB', 'no type coercion when assigning to *{} retval');
41 \$::{phake}, \*{"phake"},
42 'symbolic *{} returns symtab entry when FAKE'
44 ${\*{"phake"}} = undef;
46 ref(\$::{phake}), 'GLOB',
47 'no type coercion when assigning to retval of symbolic *{}'
52 \$::{phaque}, \*phaque,
53 "compile-time *{} returns symtab entry when FAKE"
58 ref(\$::{phaque}), 'GLOB',
59 'no type coercion when assigning to retval of compile-time *{}'
63 # type coercion on substitutions that match
72 # typeglobs as lvalues
73 substr($foo, 0, 1) = "XXX";
74 is(ref(\$foo), 'SCALAR');
75 is($foo, 'XXXmain::bar');
77 # returning glob values
79 local($bar) = *main::foo;
86 is(ref(\$fuu), 'GLOB');
90 is(ref(\$baa), 'GLOB');
92 # nested package globs
93 # NOTE: It's probably OK if these semantics change, because the
94 # fact that %X::Y:: is stored in %X:: isn't documented.
97 { package Foo::Bar; no warnings 'once'; $test=1; }
98 ok(exists $Foo::{'Bar::'});
99 is($Foo::{'Bar::'}, '*Foo::Bar::');
102 # test undef operator clearing out entire glob
104 @foo = qw(more stuff);
105 %foo = qw(even more random stuff);
112 # test warnings from assignment of undef to glob
114 local $SIG{__WARN__} = sub { $msg = $_[0] };
119 like($msg, qr/Undefined value assigned to typeglob/);
122 # test warnings for converting globs to other forms
124 foreach ($copy, *SKREEE) {
126 my $victim = sprintf "%d", $_;
127 like($msg, qr/Argument "\*main::[A-Z]{6}" isn't numeric in sprintf/,
128 "Warning on conversion to IV");
132 $victim = sprintf "%u", $_;
133 like($msg, qr/Argument "\*main::[A-Z]{6}" isn't numeric in sprintf/,
134 "Warning on conversion to UV");
138 $victim = sprintf "%e", $_;
139 like($msg, qr/Argument "\*main::[A-Z]{6}" isn't numeric in sprintf/,
140 "Warning on conversion to NV");
141 like($victim, qr/^0\.0+E\+?00/i, "Expect floating point zero");
144 $victim = sprintf "%s", $_;
145 is($msg, '', "No warning on stringification");
146 is($victim, '' . $_);
150 my $test = curr_test();
151 # test *glob{THING} syntax
156 %x = ("ok $test" => "\n");
158 sub x { "ok $test\n" }
159 print ${*x{SCALAR}}, @{*x{ARRAY}}, %{*x{HASH}}, &{*x{CODE}};
160 # This needs to go here, after the print, as sub x will return the current
164 XXX This text isn't used. Should it be?
168 is (ref *x{FORMAT}, "FORMAT");
169 is ("@{sub { *_{ARRAY} }->(1..3)}", "1 2 3",
170 'returning *_{ARRAY} from sub');
172 is (*{*x{GLOB}}, "*main::STDOUT");
175 my $test = curr_test();
177 print {*x{IO}} "ok $test\n";
181 local $SIG{__WARN__} = sub {
184 my $val = *x{FILEHANDLE};
185 print {*x{IO}} ($warn =~ /is deprecated/
186 ? "ok $test\n" : "not ok $test\n");
190 is *x{NAME}, 'x', '*foo{NAME}';
191 is *x{PACKAGE}, 'main', '*foo{PACKAGE}';
192 { no warnings 'once'; *x = *Foo::y; }
193 is *x, '*Foo::y', 'glob stringifies as assignee after glob-to-glob assign';
194 is *x{NAME}, 'x', 'but *foo{NAME} still returns the original name';
195 is *x{PACKAGE}, 'main', 'and *foo{PACKAGE} the original package';
198 # test if defined() doesn't create any new symbols
204 no warnings 'deprecated';
210 no warnings 'deprecated';
222 *{$a} = sub { $state = "ok" };
230 # although it *should* if you're talking about magicals
247 "o" =~ /(((((((((((o)))))))))))/;
252 # [ID 20010526.001] localized glob loses value when assigned to
254 $j=1; %j=(a=>1); @j=(1); local *j=*j; *j = sub{};
261 # does pp_readline() handle glob-ness correctly?
269 local $SIG{__WARN__} = sub { $w = $_[0] };
271 local *abc1 = sub { };
279 like ($w, qr/Prototype mismatch/);
283 # [17375] rcatline to formerly-defined undef was broken. Fixed in
284 # do_readline by checking SvOK. AMS, 20020918
292 # test the assignment of a GLOB to an LVALUE
294 local $SIG{__DIE__} = sub { $e = $_[0] };
296 sub f { $_[0] = 0; $_[0] = "a"; $_[0] = *DATA }
298 is ($v{v}, '*main::DATA');
299 is (ref\$v{v}, 'GLOB', 'lvalue assignment preserves globs');
300 my $x = readline $v{v};
302 is ($e, '', '__DIE__ handler never called');
307 # GLOB assignment to tied element
308 local $SIG{__DIE__} = sub { $e = $_[0] };
309 sub T::TIEARRAY { bless [] => "T" }
310 sub T::STORE { $_[0]->[ $_[1] ] = $_[2] }
311 sub T::FETCH { $_[0]->[ $_[1] ] }
312 sub T::FETCHSIZE { @{$_[0]} }
315 is ($ary[0], '*main::DATA');
317 ref\tied(@ary)->[0], 'GLOB',
318 'tied elem assignment preserves globs'
320 is ($e, '', '__DIE__ handler not called');
321 my $x = readline $ary[0];
323 is ($e, '', '__DIE__ handler never called');
327 # Need some sort of die or warn to get the global destruction text if the
328 # bug is still present
329 my $output = runperl(prog => <<'EOPROG');
332 sub DESTROY {eval {die qq{Farewell $_[0]}}; print $@}
338 like($output, qr/^Farewell M=SCALAR/, "DESTROY was called");
339 unlike($output, qr/global destruction/,
340 "unreferenced symbol tables should be cleaned up immediately");
343 # Possibly not the correct test file for these tests.
344 # There are certain space optimisations implemented via promotion rules to
347 foreach (qw (oonk ga_shloip)) {
348 ok(!exists $::{$_}, "no symbols of any sort to start with for $_");
351 # A string in place of the typeglob is promoted to the function prototype
353 my $proto = eval 'prototype \&oonk';
355 is ($proto, "pie", "String is promoted to prototype");
358 # A reference to a value is used to generate a constant subroutine
359 foreach my $value (3, "Perl rules", \42, qr/whatever/, [1,2,3], {1=>2},
360 \*STDIN, \&ok, \undef, *STDOUT) {
363 $proto = eval 'prototype \&oonk';
365 is ($proto, '', "Prototype for a constant subroutine is empty");
367 my $got = eval 'oonk';
369 is (ref $got, ref $value, "Correct type of value (" . ref($value) . ")");
370 is ($got, $value, "Value is correctly set");
374 $::{oonk} = \"Value";
376 *{"ga_shloip"} = \&{"oonk"};
378 is (ref $::{ga_shloip}, 'SCALAR', "Export of proxy constant as is");
379 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
380 is (eval 'ga_shloip', "Value", "Constant has correct value");
381 is (ref $::{ga_shloip}, 'SCALAR',
382 "Inlining of constant doesn't change representation");
384 delete $::{ga_shloip};
386 eval 'sub ga_shloip (); 1' or die $@;
387 is ($::{ga_shloip}, '', "Prototype is stored as an empty string");
389 # Check that a prototype expands.
390 *{"ga_shloip"} = \&{"oonk"};
392 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
393 is (eval 'ga_shloip', "Value", "Constant has correct value");
394 is (ref \$::{ga_shloip}, 'GLOB', "Symbol table has full typeglob");
399 # Check that assignment to an existing typeglob works
402 local $SIG{__WARN__} = sub { $w = $_[0] };
403 *{"zwot"} = \&{"oonk"};
404 is($w, '', "Should be no warning");
407 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
408 is (eval 'zwot', "Value", "Constant has correct value");
409 is (ref \$::{zwot}, 'GLOB', "Symbol table has full typeglob");
410 is (join ('!', @::zwot), 'Zwot!', "Existing array still in typeglob");
416 # Check that assignment to an existing subroutine works
419 local $SIG{__WARN__} = sub { $w = $_[0] };
420 *{"spritsits"} = \&{"oonk"};
421 like($w, qr/^Constant subroutine main::spritsits redefined/,
422 "Redefining a constant sub should warn");
425 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
426 is (eval 'spritsits', "Value", "Constant has correct value");
427 is (ref \$::{spritsits}, 'GLOB', "Symbol table has full typeglob");
429 # Check that assignment to an existing typeglob works
432 local $SIG{__WARN__} = sub { $w = $_[0] };
434 *{"plunk"} = \&{"oonk"};
435 is($w, '', "Should be no warning");
438 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
439 is (eval 'plunk', "Value", "Constant has correct value");
440 is (ref \$::{plunk}, 'GLOB', "Symbol table has full typeglob");
442 my $gr = eval '\*plunk' or die;
446 local $SIG{__WARN__} = sub { $w = $_[0] };
448 is($w, '', "Redefining a constant sub to another constant sub with the same underlying value should not warn (It's just re-exporting, and that was always legal)");
451 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
452 is (eval 'plunk', "Value", "Constant has correct value");
453 is (ref \$::{plunk}, 'GLOB', "Symbol table has full typeglob");
455 # Non-void context should defeat the optimisation, and will cause the original
456 # to be promoted (what change 26482 intended)
460 local $SIG{__WARN__} = sub { $w = $_[0] };
461 $result = *{"awkkkkkk"} = \&{"oonk"};
462 is($w, '', "Should be no warning");
465 is (ref \$result, 'GLOB',
466 "Non void assignment should still return a typeglob");
468 is (ref \$::{oonk}, 'GLOB', "This export does affect original");
469 is (eval 'plunk', "Value", "Constant has correct value");
470 is (ref \$::{plunk}, 'GLOB', "Symbol table has full typeglob");
473 $::{oonk} = \"Value";
477 local $SIG{__WARN__} = sub { $w = $_[0] };
478 *{"zap"} = \&{"oonk"};
479 is($w, '', "Should be no warning");
483 is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");
484 is (eval 'zap', "Value", "Constant has correct value");
485 is (ref $::{zap}, 'SCALAR', "Exported target is also a PCS");
488 local $SIG{__WARN__} = sub { die $_[0] };
489 *{"biff"} = \&{"oonk"};
493 is (ref \$::{oonk}, 'GLOB', "This export does affect original");
494 is (eval 'biff', "Value", "Constant has correct value");
495 is (ref \$::{biff}, 'GLOB', "Symbol table has full typeglob");
497 $::{yarrow} = [4,5,6];
498 is join("-", eval "yarrow()"), '4-5-6', 'array ref as stash elem';
499 is ref $::{yarrow}, "ARRAY", 'stash elem is still array ref after use';
500 is join("-", eval "&yarrow"), '4-5-6', 'calling const list with &';
501 is join("-", eval "&yarrow(1..10)"), '4-5-6', 'const list ignores & args';
502 is prototype "yarrow", "", 'const list has "" prototype';
503 is eval "yarrow", 3, 'const list in scalar cx returns length';
506 use vars qw($glook $smek $foof);
507 # Check reference assignment isn't affected by the SV type (bug #38439)
510 $foof = "halt and cool down";
519 is($foof, "halt and cool down");
527 foreach my $value ({1=>2}, *STDOUT{IO}, \&ok, *STDOUT{FORMAT}) {
528 # *STDOUT{IO} returns a reference to a PVIO. As it's blessed, ref returns
529 # IO::Handle, which isn't what we want.
535 $proto = eval 'prototype \&oonk';
536 like ($@, qr/^Cannot convert a reference to $type to typeglob/,
537 "Cannot upgrade ref-to-$type to typeglob");
541 no warnings qw(once uninitialized);
543 my $r = eval {no strict; ${*{$g}{SCALAR}}};
544 is ($@, '', "PERL_DONT_CREATE_GVSV shouldn't affect thingy syntax");
547 $r = eval {use strict; ${*{$g}{SCALAR}}};
549 "PERL_DONT_CREATE_GVSV shouldn't affect thingy syntax under strict");
553 # Bug reported by broquaint on IRC
554 *slosh::{HASH}->{ISA}=[];
556 pass("gv_fetchmeth coped with the unexpected");
558 # An audit found these:
567 like ($@, qr/^Can't locate object method "rip"/, "Even with SUPER");
569 is(slosh->isa('swoosh'), '');
571 $CORE::GLOBAL::{"lock"}=[];
572 eval "no warnings; lock";
573 like($@, qr/^Not enough arguments for lock/,
574 "Can't trip up general keyword overloading");
576 $CORE::GLOBAL::{"readline"}=[];
577 eval "<STDOUT> if 0";
578 is($@, '', "Can't trip up readline overloading");
580 $CORE::GLOBAL::{"readpipe"}=[];
582 is($@, '', "Can't trip up readpipe overloading");
586 die if exists $::{BONK};
587 $::{BONK} = \"powie";
588 *{"BONK"} = \&{"BONK"};
589 eval 'is(BONK(), "powie",
590 "Assignment works when glob created midway (bug 45607)"); 1'
594 # For now these tests are here, but they would probably be better in a file for
595 # tests for croaks. (And in turn, that probably deserves to be in a different
596 # directory. Gerard Goossen has a point about the layout being unclear
599 no warnings 'numeric';
603 no warnings 'numeric';
610 foreach my $type (qw(integer number string)) {
611 my $prog = "coerce_$type(*STDERR)";
612 is (scalar eval "$prog; 1", undef, "$prog failed...");
613 like ($@, qr/Can't coerce GLOB to $type in/,
614 "with the correct error message");
617 # RT #65582 anonymous glob should be defined, and not coredump when
618 # stringified. The behaviours are:
620 # defined($glob) "$glob" $glob .= ...
621 # 5.8.8 false "" with uninit warning "" with uninit warning
622 # 5.10.0 true (coredump) (coredump)
623 # 5.1[24] true "" "" with uninit warning
624 # 5.16 true "*__ANON__::..." "*__ANON__::..."
627 my $io_ref = *STDOUT{IO};
629 ok(defined $glob, "RT #65582 anon glob should be defined");
632 local $SIG{__WARN__} = sub { $warn = $_[0] };
635 is($warn, '', "RT #65582 anon glob stringification shouldn't warn");
636 is($str, '*__ANON__::__ANONIO__',
637 "RT #65582/#96326 anon glob stringification");
640 # Another stringification bug: Test that recursion does not cause lexical
641 # handles to lose their names.
644 @output = r($_[0]-1) if $_[0];
651 '*main::$fh *main::$fh *main::$fh *main::$fh *main::$fh',
652 'recursion does not cause lex handles to lose their names';
654 # [perl #71254] - Assigning a glob to a variable that has a current
655 # match position. (We are testing that Perl_magic_setmglob respects globs'
656 # special used of SvSCREAM.)
658 $m = 2; $m=~s/./0/gems; $m= *STDERR;
660 "$m", "*main::STDERR",
661 '[perl #71254] assignment of globs to vars with pos'
665 # [perl #72740] - indirect object syntax, heuristically imputed due to
666 # the non-existence of a function, should not cause a stash entry to be
667 # created for the non-existent function.
670 my $f = bless({}, RT72740b);
677 sub s2 { "RT72740b::s2" }
678 sub s4 { "RT72740b::s4" }
680 ok(exists($RT72740a::{s1}), "RT72740a::s1 exists");
681 ok(!exists($RT72740a::{s2}), "RT72740a::s2 does not exist");
682 ok(exists($RT72740a::{s3}), "RT72740a::s3 exists");
683 ok(exists($RT72740a::{s4}), "RT72740a::s4 exists");
684 is(RT72740a::s1(), "RT72740b::s2", "RT72740::s1 parsed correctly");
685 is(RT72740a::s3(), "RT72740b::s4", "RT72740::s3 parsed correctly");
687 # [perl #71686] Globs that are in symbol table can be un-globbed
690 is (eval 'local *::fake = \"chuck"; $fake', 'chuck',
691 "Localized glob didn't coerce into a RV");
692 is ($@, '', "Can localize FAKE glob that's present in stash");
693 is (scalar $::{fake}, "*main::sym",
694 "Localized FAKE glob's value was correctly restored");
696 # [perl #1804] *$x assignment when $x is a copy of another glob
697 # And [perl #77508] (same thing with list assignment)
700 my $x = *_random::glob_that_is_not_used_elsewhere;
703 "$x", '*_random::glob_that_is_not_used_elsewhere',
704 '[perl #1804] *$x assignment when $x is FAKE',
706 $x = *_random::glob_that_is_not_used_elsewhere;
707 (my $dummy, *$x) = (undef,[]);
709 "$x", '*_random::glob_that_is_not_used_elsewhere',
710 '[perl #77508] *$x list assignment when $x is FAKE',
711 ) or require Devel::Peek, Devel::Peek::Dump($x);
715 # this caused panics or 'Attempt to free unreferenced scalar'
716 # (its a compile-time issue, so the die lets us skip the prints)
719 local $SIG{__WARN__} = sub { push @warnings, @_ };
722 BEGIN { $::{FOO} = \'bar' }
728 like($@, qr/made it/, "#76540 - no panic");
729 ok(!@warnings, "#76540 - no 'Attempt to free unreferenced scalar'");
732 # [perl #77362] various bugs related to globs as PVLVs
734 no warnings qw 'once void';
735 my %h; # We pass a key of this hash to the subroutine to get a PVLV.
737 # Set up our glob-as-PVLV
740 # Bad symbol for array
741 ok eval{ @$_; 1 }, 'PVLV glob slots can be autovivified' or diag $@;
743 # This should call TIEHANDLE, not TIESCALAR
744 *thext::TIEHANDLE = sub{};
745 ok eval{ tie *$_, 'thext'; 1 }, 'PVLV globs can be tied as handles'
748 # Assigning undef to the glob should not overwrite it...
751 local $SIG{__WARN__} = sub { $w = shift };
753 is $_, "*main::hon", 'PVLV: assigning undef to the glob does nothing';
754 like $w, qr\Undefined value assigned to typeglob\,
755 'PVLV: assigning undef to the glob warns';
758 # Neither should reference assignment.
760 is $_, "*main::hon", "PVLV: arrayref assignment assigns to the AV slot";
762 # Concatenation should still work.
763 ok eval { $_ .= 'thlew' }, 'PVLV concatenation does not die' or diag $@;
764 is $_, '*main::honthlew', 'PVLV concatenation works';
766 # And we should be able to overwrite it with a string, number, or refer-
767 # ence, too, if we omit the *.
768 $_ = *hon; $_ = 'tzor';
769 is $_, 'tzor', 'PVLV: assigning a string over a glob';
771 is $_, 23, 'PVLV: assigning an integer over a glob';
772 $_ = *hon; $_ = 23.23;
773 is $_, 23.23, 'PVLV: assigning a float over a glob';
774 $_ = *hon; $_ = \my $sthat;
775 is $_, \$sthat, 'PVLV: assigning a reference over a glob';
777 # This bug was found by code inspection. Could this ever happen in
779 # This duplicates a file handle, accessing it through a PVLV glob, the
780 # glob having been removed from the symbol table, so a stringified form
781 # of it does not work. This checks that sv_2io does not stringify a PVLV.
783 open *quin, "test.pl"; # test.pl is as good a file as any
785 ok eval { open my $zow, "<&", $_ }, 'PVLV: sv_2io stringifieth not'
788 # Similar tests to make sure sv_2cv etc. do not stringify.
790 ok eval { &$_ }, "PVLV glob can be called as a sub" or diag $@;
793 is eval { &$_ }, 2, 'PVLV holding a string can be called as a sub'
796 # Coderef-to-glob assignment when the glob is no longer accessible
797 # under its name: These tests are to make sure the OPpASSIGN_CV_TO_GV
798 # optimisation takes PVLVs into account, which is why the RHSs have to be
800 use constant gheen => 'quare';
804 is eval { &$_ }, 'quare',
805 'PVLV: constant assignment when the glob is detached from the symtab'
809 *gheck = sub { 'lon' };
811 is eval { &$_ }, 'lon',
812 'PVLV: coderef assignment when the glob is detached from the symtab'
816 skip_if_miniperl("no dynamic loading on miniperl, so can't load PerlIO::scalar", 1);
817 # open should accept a PVLV as its first argument
819 ok eval { open $_,'<', \my $thlext }, 'PVLV can be the first arg to open'
823 # -t should not stringify
824 $_ = *thlit; delete $::{thlit};
826 ok defined -t $_, 'PVLV: -t does not stringify';
829 # but some systems don’t support this on file handles
833 open my $quile, "<", 'test.pl';
837 } ? $pass : $@ =~ /not implemented on filehandles/,
838 "PVLV: -T does not stringify";
840 # Unopened file handle
843 local $SIG{__WARN__} = sub { $w .= shift };
846 like $w, qr\unopened filehandle vor\,
847 'PVLV globs get their names reported in unopened error messages';
854 pass('Can assign integers to typeglobs');
856 pass('Can assign floats to typeglobs');
858 pass('Can assign strings to typeglobs');
862 sub TIESCALAR{bless[]}
863 sub STORE{ die "No!"}
864 sub FETCH{ no warnings 'once'; *thrit }
866 () = "$a"; # do a fetch; now $a holds a glob
867 eval { *$a = sub{} };
871 "[perl #77812] Globs in tied scalars can be reified if STORE dies"
874 # These two crashed prior to 5.13.6. In 5.13.6 they were fatal errors. They
875 # were fixed in 5.13.7.
877 my $glob = \*heen::ISA;
878 delete $::{"heen::"};
880 }, "glob-to-*ISA assignment works when *ISA has lost its stash";
882 my $glob = \*slare::ISA;
883 delete $::{"slare::"};
885 }, "array-to-*ISA assignment works when *ISA has lost its stash";
886 # These two crashed in 5.13.6. They were likewise fixed in 5.13.7.
889 my $glob = do { no warnings "once"; \*phing::foo};
890 delete $::{"phing::"};
892 }, "Assigning a glob-with-sub to a glob that has lost its stash works";
895 my $glob = \*pon::foo;
898 }, "Assigning a glob to a glob-with-sub that has lost its stash works";
902 sub TIESCALAR{ bless \\pop }
903 sub FETCH { $${$_[0]} }
904 sub STORE { $${$_[0]} = $_[1] }
906 tie my $alias, 'Tie::Alias', my $var;
912 is $alias, 3, "[perl #77926] Glob reification during localisation";
916 # This code causes gp_free to call a destructor when a glob is being
917 # restored on scope exit. The destructor used to see SVs with a refcount of
918 # zero inside the glob, which could result in crashes (though not in this
919 # test case, which just panics).
923 *Trit::DESTROY = sub {
924 $thwext = 42; # panic
929 $thwext = bless[],'Trit';
933 'no error when gp_free calls a destructor that assigns to the gv';
937 eval { *{my $undef} = 3 };
938 like $@, qr/^Can't use an undefined value as a symbol reference at /,
939 '*{ $undef } assignment';
940 eval { *{;undef} = 3 };
941 like $@, qr/^Can't use an undefined value as a symbol reference at /,
942 '*{ ;undef } assignment';
944 # [perl #99142] defined &{"foo"} when there is a constant stub
945 # If I break your module, you get to have it mentioned in Perl's tests. :-)
946 package HTTP::MobileAttribute::Plugin::Locator {
947 use constant LOCATOR_GPS => 1;
948 ::ok defined &{__PACKAGE__."::LOCATOR_GPS"},
949 'defined &{"name of constant"}';
950 ::ok Internals::SvREFCNT(${__PACKAGE__."::"}{LOCATOR_GPS}),
951 "stash elem for slot is not freed prematurely";
954 # Check that constants promoted to CVs point to the right GVs when the name
958 # These two lines abuse the optimisation that copies the scalar ref from
959 # one stash element to another, to get a constant with a null in its name
960 *{"yz\0a"} = \&{"x"};
961 my $ref = \&{"yz\0a"};
962 ::ok !exists $lrcg::{yz},
963 'constants w/nulls in their names point 2 the right GVs when promoted';
967 # This violates perl's internal structures by fiddling with stashes in a
968 # way that should never happen, but perl should not start trying to free
969 # unallocated memory as a result. There is no ok() or is() because the
970 # panic that used to occur only occurred during global destruction, and
971 # only with PERL_DESTRUCT_LEVEL=2. (The panic itself was sufficient for
972 # the harness to consider this test script to have failed.)
973 $::{aoeuaoeuaoeaoeu} = __PACKAGE__; # cow
974 () = *{"aoeuaoeuaoeaoeu"};
980 pass "No crash due to CvGV(vivified stub) pointing to flattened glob copy";
981 # Not really supported, but this should not crash either:
983 delete $::{_119051again};
984 $::{_119051again} = $x; # now we have a fake glob under the right name
985 $y = \&$x; # so when this tries to look up the right GV for
986 undef $::{_119051again}; # CvGV, it still gets a fake one
988 pass "No crash due to CvGV pointing to glob copy in the stash";