File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -40,4 +40,34 @@ no warnings 'experimental::class';
4040 is(Test3::Foo-> new-> hello, " This" , ' Class supports fully-qualified package names' );
4141}
4242
43+ # Class {BLOCK} syntax parses like package
44+ {
45+ my $result = " " ;
46+ eval q{
47+ $result .= "a(" . __PACKAGE__ . "/" . eval("__PACKAGE__") . ")\n";
48+ class Test4 1.23 {
49+ $result .= "b(" . __PACKAGE__ . "/" . eval("__PACKAGE__") . ")\n ";
50+ }
51+ $result .= "c(" . __PACKAGE__ . "/" . eval("__PACKAGE__") . ")\n";
52+ } or die $@ ;
53+ is($result , " a(main/main)\n b(Test4/Test4)\n c(main/main)\n " ,
54+ ' class sets __PACKAGE__ correctly' );
55+ is($Test4::VERSION , 1.23, ' class NAME VERSION { BLOCK } sets $VERSION' );
56+ }
57+
58+ # Unit class syntax parses like package
59+ {
60+ my $result = " " ;
61+ eval q{
62+ $result .= "a(" . __PACKAGE__ . "/" . eval("__PACKAGE__") . ")\n";
63+ class Test5 4.56;
64+ $result .= "b(" . __PACKAGE__ . "/" . eval("__PACKAGE__") . ")\n";
65+ package main;
66+ $result .= "c(" . __PACKAGE__ . "/" . eval("__PACKAGE__") . ")\n";
67+ } or die $@ ;
68+ is($result , " a(main/main)\n b(Test5/Test5)\n c(main/main)\n " ,
69+ ' class sets __PACKAGE__ correctly' );
70+ is($Test5::VERSION , 4.56, ' class NAME VERSION; sets $VERSION' );
71+ }
72+
4373done_testing;
You can’t perform that action at this time.
0 commit comments