BEGIN { require "./test.pl"; }
-plan( tests => 53 );
+plan( tests => 50 );
# Used to segfault (bug #15479)
fresh_perl_like(
- '%:: = ""',
+ 'delete $::{STDERR}; my %a = ""',
qr/Odd number of elements in hash assignment at - line 1\./,
{ switches => [ '-w' ] },
'delete $::{STDERR} and print a warning',
q(Insert a non-GV in a stash, under warnings 'once'),
);
-{
- no warnings 'deprecated';
- ok( defined %oedipa::maas::, q(stashes happen to be defined if not used) );
- ok( defined %{"oedipa::maas::"}, q(- work with hard refs too) );
-
- ok( defined %tyrone::slothrop::, q(stashes are defined if seen at compile time) );
- ok( defined %{"tyrone::slothrop::"}, q(- work with hard refs too) );
-
- ok( defined %bongo::shaftsbury::, q(stashes are defined if a var is seen at compile time) );
- ok( defined %{"bongo::shaftsbury::"}, q(- work with hard refs too) );
+# Used to segfault, too
+SKIP: {
+ skip_if_miniperl('requires XS');
+ fresh_perl_like(
+ 'sub foo::bar{}; $mro::{get_mro}=*foo::bar; undef %foo::; require mro',
+ qr/^Subroutine mro::get_mro redefined at /,
+ { switches => [ '-w' ] },
+ q(Defining an XSUB over an existing sub with no stash under warnings),
+ );
}
package tyrone::slothrop;
{
local $ENV{PERL_DESTRUCT_LEVEL} = 2;
fresh_perl_is(
- 'package A; sub a { // }; %::=""',
+ 'package A::B; sub a { // }; %A::=""',
'',
+ {},
+ );
+ # Variant of the above which creates an object that persists until global
+ # destruction, and triggers an assertion failure prior to change
+ # a420522db95b7762
+ fresh_perl_is(
+ 'use Exporter; package A; sub a { // }; delete $::{$_} for keys %::',
'',
+ {},
);
}
-# now tests in eval
-
-ok( eval { no warnings 'deprecated'; defined %achtfaden:: }, 'works in eval{}' );
-ok( eval q{ no warnings 'deprecated'; defined %schoenmaker:: }, 'works in eval("")' );
-
# now tests with strictures
{
use strict;
- no warnings 'deprecated';
- ok( defined %pig::, q(referencing a non-existent stash doesn't produce stricture errors) );
ok( !exists $pig::{bodine}, q(referencing a non-existent stash element doesn't produce stricture errors) );
}
SKIP: {
- eval { require B; 1 } or skip "no B", 27;
+ eval { require B; 1 } or skip "no B", 29;
*b = \&B::svref_2object;
my $CVf_ANON = B::CVf_ANON();
delete $one::{one};
my $gv = b($sub)->GV;
- isa_ok( $gv, "B::GV", "deleted stash entry leaves CV with valid GV");
+ object_ok( $gv, "B::GV", "deleted stash entry leaves CV with valid GV");
is( b($sub)->CvFLAGS & $CVf_ANON, $CVf_ANON, "...and CVf_ANON set");
is( eval { $gv->NAME }, "__ANON__", "...and an __ANON__ name");
is( eval { $gv->STASH->NAME }, "one", "...but leaves stash intact");
%two:: = ();
$gv = b($sub)->GV;
- isa_ok( $gv, "B::GV", "cleared stash leaves CV with valid GV");
+ object_ok( $gv, "B::GV", "cleared stash leaves CV with valid GV");
is( b($sub)->CvFLAGS & $CVf_ANON, $CVf_ANON, "...and CVf_ANON set");
is( eval { $gv->NAME }, "__ANON__", "...and an __ANON__ name");
is( eval { $gv->STASH->NAME }, "two", "...but leaves stash intact");
undef %three::;
$gv = b($sub)->GV;
- isa_ok( $gv, "B::GV", "undefed stash leaves CV with valid GV");
+ object_ok( $gv, "B::GV", "undefed stash leaves CV with valid GV");
is( b($sub)->CvFLAGS & $CVf_ANON, $CVf_ANON, "...and CVf_ANON set");
is( eval { $gv->NAME }, "__ANON__", "...and an __ANON__ name");
is( eval { $gv->STASH->NAME }, "__ANON__", "...and an __ANON__ stash");
'ref() returns the same thing when an object’s stash is moved';
::like "$obj", qr "^rile=ARRAY\(0x[\da-f]+\)\z",
'objects stringify the same way when their stashes are moved';
- {
- local $::TODO = $Config{useithreads} ? "fails under threads" : undef;
- ::is eval '__PACKAGE__', 'rile',
+ ::is eval '__PACKAGE__', 'rile',
'__PACKAGE__ returns the same when the current stash is moved';
- }
# Now detach it completely from the symtab, making it effect-
# ively anonymous
'ref() returns the same thing when an object’s stash is detached';
::like "$obj", qr "^rile=ARRAY\(0x[\da-f]+\)\z",
'objects stringify the same way when their stashes are detached';
- {
- local $::TODO = $Config{useithreads} ? "fails under threads" : undef;
- ::is eval '__PACKAGE__', 'rile',
+ ::is eval '__PACKAGE__', 'rile',
'__PACKAGE__ returns the same when the current stash is detached';
- }
}
# Setting the name during undef %stash:: should have no effect.
"setting stash name during undef has no effect";
}
+# [perl #88134] incorrect package structure
+{
+ package Bear::;
+ sub baz{1}
+ package main;
+ ok eval { Bear::::baz() },
+ 'packages ending with :: are self-consistent';
+}
+
+# [perl #88138] ' not equivalent to :: before a null
+${"a'\0b"} = "c";
+is ${"a::\0b"}, "c", "' is equivalent to :: before a null";
+
+# [perl #101486] Clobbering the current package
+ok eval '
+ package Do;
+ BEGIN { *Do:: = *Re:: }
+ sub foo{};
+ 1
+ ', 'no crashing or errors when clobbering the current package';
+
+# Bareword lookup should not vivify stashes
+is runperl(
+ prog =>
+ 'sub foo { print shift, qq-\n- } SUPER::foo bar if 0; foo SUPER',
+ stderr => 1,
+ ),
+ "SUPER\n",
+ 'bareword lookup does not vivify stashes';