This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
support "package Foo { ... }"
[perl5.git] / t / comp / package_block.t
1 #!./perl
2
3 print "1..3\n";
4
5 $main::result = "";
6 eval 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 };
17 print $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 = "";
21 eval 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 };
27 print $main::result eq "a(11)b(22)c(Bar)" ? "ok 2\n" : "not ok 2\n";
28
29 $main::result = "";
30 eval q{
31         $main::result .= "a(".__PACKAGE__.")";
32         package Foo { }
33         $main::result .= "b(".__PACKAGE__.")";
34 };
35 print $main::result eq "a(main)b(main)" ? "ok 3\n" : "not ok 3\n";
36
37 1;