summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-04-19 20:37:25 +0100
committerDavid Golden <dagolden@cpan.org>2010-05-20 18:56:11 -0400
commit4e4da3acc11d96d134ed1dc0effd641e7bedb0ca (patch)
treece3ff5f214a7e854b3065056f8cb48208ba47e30 /t
parent39f3f7f442aed93239540238d19a15f6020da747 (diff)
downloadperl-4e4da3acc11d96d134ed1dc0effd641e7bedb0ca.tar.gz
support "package Foo { ... }"
Package block syntax limits the scope of the package declaration to the attached block. It's cleaner than requiring the declaration to come inside the block.
Diffstat (limited to 't')
-rw-r--r--t/comp/package_block.t37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/comp/package_block.t b/t/comp/package_block.t
new file mode 100644
index 0000000000..8645f1a175
--- /dev/null
+++ b/t/comp/package_block.t
@@ -0,0 +1,37 @@
+#!./perl
+
+print "1..3\n";
+
+$main::result = "";
+eval q{
+ $main::result .= "a(".__PACKAGE__.")";
+ package Foo {
+ $main::result .= "b(".__PACKAGE__.")";
+ package Bar::Baz {
+ $main::result .= "c(".__PACKAGE__.")";
+ }
+ $main::result .= "d(".__PACKAGE__.")";
+ }
+ $main::result .= "e(".__PACKAGE__.")";
+};
+print $main::result eq "a(main)b(Foo)c(Bar::Baz)d(Foo)e(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__.")"; }
+};
+print $main::result eq "a(11)b(22)c(Bar)" ? "ok 2\n" : "not ok 2\n";
+
+$main::result = "";
+eval q{
+ $main::result .= "a(".__PACKAGE__.")";
+ package Foo { }
+ $main::result .= "b(".__PACKAGE__.")";
+};
+print $main::result eq "a(main)b(main)" ? "ok 3\n" : "not ok 3\n";
+
+1;