perl/t/comp/package_block.t
James E Keenan d306795336 Fatalize use of goto to jump into construct
* Adapt all tests.

* Revise discussion of 'goto' in perlfunc.

* Perl 5.44 fatalization: document goto_construct Also, note that no
  deprecations or fatalizations occurred in perl-5.42.

* Remove 'goto_construct' from list of warnings.  This entails:

** Entering 'deprecated::goto_construct" into %NO_BIT_FOR inside
regen/warnings.pl;

** Incrementing $VERSION in that file;

** Running `make regen` to propagate these changes to lib/warnings.pm and
warnings.h, in the process renumbering the warnings categories and
adding 'deprecated::goto_construct' to %NoOp inside lib/warnings.pm.

* Add entry to perldiag.pod

* Update perldelta: partial fatalization of goto construct.

* t/op/goto.t: Restore tests deleted during work on branch.
2025-12-16 10:13:47 -05:00

58 lines
1.6 KiB
Perl

#!./perl
print "1..5\n";
$main::result = "";
eval q{
$main::result .= "a(".__PACKAGE__."/".eval("__PACKAGE__").")";
package Foo {
$main::result .= "b(".__PACKAGE__."/".eval("__PACKAGE__").")";
package Bar::Baz {
$main::result .= "c(".__PACKAGE__."/".eval("__PACKAGE__").")";
}
$main::result .= "d(".__PACKAGE__."/".eval("__PACKAGE__").")";
}
$main::result .= "e(".__PACKAGE__."/".eval("__PACKAGE__").")";
};
print $main::result eq
"a(main/main)b(Foo/Foo)c(Bar::Baz/Bar::Baz)d(Foo/Foo)e(main/main)" ?
"ok 1\n" : "not ok 1\n";
$main::result = "";
eval q{
$main::result .= "a($Foo::VERSION)";
$main::result .= "b($Bar::VERSION)";
package Foo 11 { ; }
package Bar 22 {
$main::result .= "c(".__PACKAGE__."/".eval("__PACKAGE__").")";
}
};
print $main::result eq "a(11)b(22)c(Bar/Bar)" ? "ok 2\n" : "not ok 2\n";
$main::result = "";
eval q{
$main::result .= "a(".__PACKAGE__."/".eval("__PACKAGE__").")";
package Foo { }
$main::result .= "b(".__PACKAGE__."/".eval("__PACKAGE__").")";
};
print $main::result eq "a(main/main)b(main/main)" ? "ok 3\n" : "not ok 3\n";
eval q[package Foo {];
print $@ =~ /\AMissing right curly / ? "ok 4\n" : "not ok 4\n";
$main::result = "";
eval q{
$main::result .= "a(".__LINE__.")";
package Foo {
$main::result .= "b(".__LINE__.")";
package Bar::Baz {
$main::result .= "c(".__LINE__.")";
}
$main::result .= "d(".__LINE__.")";
}
$main::result .= "e(".__LINE__.")";
package Quux { }
$main::result .= "f(".__LINE__.")";
};
print $main::result eq "a(2)b(4)c(6)d(8)e(10)f(12)" ? "ok 5\n" : "not ok 5\n";