This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix SEGV with eval("package Foo {")
[perl5.git] / t / comp / package_block.t
CommitLineData
4e4da3ac
Z
1#!./perl
2
af5050ac 3print "1..4\n";
4e4da3ac
Z
4
5$main::result = "";
6eval q{
7 $main::result .= "a(".__PACKAGE__.")";
8 package Foo {
9 $main::result .= "b(".__PACKAGE__.")";
10 package Bar::Baz {
11 $main::result .= "c(".__PACKAGE__.")";
12 }
13 $main::result .= "d(".__PACKAGE__.")";
14 }
15 $main::result .= "e(".__PACKAGE__.")";
16};
17print $main::result eq "a(main)b(Foo)c(Bar::Baz)d(Foo)e(main)" ?
18 "ok 1\n" : "not ok 1\n";
19
20$main::result = "";
21eval q{
22 $main::result .= "a($Foo::VERSION)";
23 $main::result .= "b($Bar::VERSION)";
24 package Foo 11 { ; }
25 package Bar 22 { $main::result .= "c(".__PACKAGE__.")"; }
26};
27print $main::result eq "a(11)b(22)c(Bar)" ? "ok 2\n" : "not ok 2\n";
28
29$main::result = "";
30eval q{
31 $main::result .= "a(".__PACKAGE__.")";
32 package Foo { }
33 $main::result .= "b(".__PACKAGE__.")";
34};
35print $main::result eq "a(main)b(main)" ? "ok 3\n" : "not ok 3\n";
36
af5050ac
Z
37eval q[package Foo {];
38print $@ =~ /\AMissing right curly / ? "ok 4\n" : "not ok 4\n";
39
4e4da3ac 401;