diff options
author | Florian Ragwitz <rafl@debian.org> | 2011-06-02 13:58:22 +0200 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-06-02 10:26:15 -0500 |
commit | 68007b8e7ce535a789d2d8845ef504e07712e14b (patch) | |
tree | 9f002e78d5dda39b6ca8ae11b22049a3f78f4927 /t | |
parent | f74800779437ea9e4e7a5e85188c7a70bb4b9b91 (diff) | |
download | bread-board-declare-68007b8e7ce535a789d2d8845ef504e07712e14b.tar.gz bread-board-declare-68007b8e7ce535a789d2d8845ef504e07712e14b.zip |
Add failing test for coercing literals
Diffstat (limited to 't')
-rw-r--r-- | t/01-basic.t | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/t/01-basic.t b/t/01-basic.t index 0457bd1..d481044 100644 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -13,6 +13,7 @@ my $i; { package Foo; use Moose; + use Moose::Util::TypeConstraints; use Bread::Board::Declare; has foo => ( @@ -21,10 +22,14 @@ my $i; default => 'FOO', ); + subtype 'ArrayRefOfStr', as 'ArrayRef[Str]'; + coerce 'ArrayRefOfStr', from 'Str', via { [$_] }; + has bar => ( - is => 'ro', - isa => 'Str', - value => 'BAR', + is => 'ro', + isa => 'ArrayRefOfStr', + coerce => 1, + value => 'BAR', ); has baz => ( @@ -62,7 +67,7 @@ $i = 0; { my $foo = Foo->new; is($foo->foo, 'FOO', "normal attrs work"); - is($foo->bar, 'BAR', "literals work"); + is_deeply($foo->bar, ['BAR'], "literals work"); isa_ok($foo->baz, 'Baz'); isnt($foo->baz, $foo->baz, "new instance each time"); is($foo->quux, 'QUUX0', "block injections work"); @@ -78,7 +83,7 @@ $i = 0; quux => 'XUUQ', ); is($foo->foo, 'OOF', "normal attrs work from constructor"); - is($foo->bar, 'RAB', "constructor overrides literals"); + is_deeply($foo->bar, ['RAB'], "constructor overrides literals"); isa_ok($foo->baz, 'Baz'); is($foo->baz, $baz, "constructor overrides constructor injections"); is($foo->baz, $foo->baz, "and returns the same thing each time"); |