Skip to content

Commit

Permalink
Implement module as a synonym for package
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 23, 2010
1 parent a10c69a commit dc56884
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Decl.pm
Expand Up @@ -332,6 +332,15 @@ use CgOp;
no Moose;
}

{
package Decl::Module;
use Moose;
extends 'Decl::Package';

__PACKAGE__->meta->make_immutable;
no Moose;
}

{
package Decl::Class;
use Moose;
Expand Down
14 changes: 13 additions & 1 deletion Op.pm
Expand Up @@ -420,9 +420,10 @@ use CgOp;
has stub => (is => 'ro', isa => 'Bool', default => 0);
has body => (is => 'ro', isa => 'Body');

sub decl_class { 'Decl::Package' }
sub local_decls {
my ($self) = @_;
Decl::Package->new(stub => $self->stub, var => $self->var . "::",
$self->decl_class->new(stub => $self->stub, var => $self->var . "::",
($self->stub ? () : (body => $self->body,
bodyvar => $self->bodyvar)));
}
Expand All @@ -443,6 +444,17 @@ use CgOp;
no Moose;
}

{
package Op::ModuleDef;
use Moose;
extends 'Op::PackageDef';

sub decl_class { 'Decl::Module' }

__PACKAGE__->meta->make_immutable;
no Moose;
}

{
package Op::ClassDef;
use Moose;
Expand Down
4 changes: 3 additions & 1 deletion test.pl
Expand Up @@ -10,7 +10,7 @@ ($num)
say ("1.." ~ $num);
}

plan 95;
plan 96;

ok 1, "one is true";
ok 2, "two is also true";
Expand Down Expand Up @@ -306,4 +306,6 @@ ($num)
{
my package Foo { our $x = 42; }
ok $Foo::x == 42, "can access our vars";
my module Bar { our $x = 42; }
ok $Bar::x == 42, "module accepted too";
}

0 comments on commit dc56884

Please sign in to comment.