Created
January 9, 2010 11:35
-
-
Save melo/272865 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Xpto; | |
use Moose; | |
has built => ( | |
isa => 'Int', | |
is => 'rw', | |
clearer => 'clear_built', | |
builder => '_build_built', | |
); | |
has lazy_built => ( | |
isa => 'Int', | |
is => 'rw', | |
clearer => 'clear_lazy_built', | |
builder => '_build_lazy_built', | |
lazy => 1, | |
); | |
has def => ( | |
isa => 'Int', | |
is => 'rw', | |
clearer => 'clear_def', | |
default => 42 | |
); | |
sub _build_built {42} | |
sub _build_lazy_built {42} | |
package main; | |
use Test::More; | |
my $o = Xpto->new; | |
is($o->built, 42); | |
is($o->lazy_built, 42); | |
is($o->def, 42); | |
$o->clear_built; | |
$o->clear_lazy_built; | |
$o->clear_def; | |
ok(!defined($o->built)); | |
ok(!defined($o->def)); | |
is($o->lazy_built, 42); | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment