diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-02-21 02:00:06 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-02-21 02:00:06 -0600 |
commit | 0a7125e470e2067f75faf81f7e1890bc402e5e98 (patch) | |
tree | a6dd03e113cf77e50096307615f6225b0fc8c4b4 | |
parent | 06f919c57dfc917e50e6858100cfbe3a1b57a1be (diff) | |
download | bread-board-declare-0a7125e470e2067f75faf81f7e1890bc402e5e98.tar.gz bread-board-declare-0a7125e470e2067f75faf81f7e1890bc402e5e98.zip |
test for mop stuff
-rw-r--r-- | t/01-basic.t | 1 | ||||
-rw-r--r-- | t/40-mop.t | 38 |
2 files changed, 39 insertions, 0 deletions
diff --git a/t/01-basic.t b/t/01-basic.t index c59a429..38590df 100644 --- a/t/01-basic.t +++ b/t/01-basic.t @@ -44,6 +44,7 @@ with_immutable { $i = 0; { my $foo = Foo->new; + isa_ok($foo, 'Bread::Board::Container'); ok($foo->has_service($_), "has service $_") for qw(bar baz quux); ok(!$foo->has_service('foo'), "doesn't have service foo"); diff --git a/t/40-mop.t b/t/40-mop.t new file mode 100644 index 0000000..c8f0dd9 --- /dev/null +++ b/t/40-mop.t @@ -0,0 +1,38 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +{ + package Foo; + use Moose; + use MooseX::Bread::Board; + + has foo => ( + is => 'ro', + isa => 'Str', + value => 'FOO', + ); + + has bar => ( + is => 'ro', + isa => 'Str', + block => sub { + my $s = shift; + return $s->param('foo') . 'BAR'; + }, + dependencies => ['foo'], + ); +} + +{ + my $foo = Foo->new; + my $foo_attr = $foo->meta->get_attribute('foo'); + my $bar_attr = $foo->meta->get_attribute('bar'); + is($foo_attr->get_value($foo), 'FOO', "right value"); + is($bar_attr->get_value($foo), 'FOOBAR', "right value"); + ok(!$foo_attr->has_value($foo), "no value"); + ok(!$bar_attr->has_value($foo), "no value"); +} + +done_testing; |