From: Ricardo SIGNES Date: Thu, 7 Feb 2008 03:42:20 +0000 (+0000) Subject: merge initializer branch, add test X-Git-Tag: 0_37~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7a9d14bdc850d60a9414a9a3660362874fc9705d;p=gitmo%2FMoose.git merge initializer branch, add test --- 7a9d14bdc850d60a9414a9a3660362874fc9705d diff --cc t/020_attributes/019_attribute_lazy_initializer.t index 0000000,0000000..c41381d new file mode 100644 --- /dev/null +++ b/t/020_attributes/019_attribute_lazy_initializer.t @@@ -1,0 -1,0 +1,45 @@@ ++#!/usr/bin/perl ++ ++use strict; ++use warnings; ++ ++use Test::More tests => 4; ++use Test::Exception; ++ ++BEGIN { ++ use_ok('Moose'); ++} ++ ++{ ++ package Foo; ++ use Moose; ++ ++ has 'foo' => ( ++ reader => 'get_foo', ++ writer => 'set_foo', ++ initializer => sub { ++ my ($self, $value, $name, $callback) = @_; ++ $callback->($value * 2); ++ }, ++ ); ++ ++ has 'lazy_foo' => ( ++ reader => 'get_lazy_foo', ++ default => 10, ++ initializer => sub { ++ my ($self, $value, $name, $callback) = @_; ++ $callback->($value * 2); ++ }, ++ ); ++} ++ ++{ ++ my $foo = Foo->new(foo => 10); ++ isa_ok($foo, 'Foo'); ++ ++ is($foo->get_foo, 20, 'initial value set to 2x given value'); ++ is($foo->get_lazy_foo, 20, 'initial lazy value set to 2x given value'); ++} ++ ++ ++