summaryrefslogtreecommitdiffstats
path: root/t/02-deps.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-02-20 02:04:52 -0600
committerJesse Luehrs <doy@tozt.net>2011-02-20 02:04:52 -0600
commit8ad579f26a1c74d5685491df55b57e694e54e087 (patch)
treede3c03114a1932c1ddbb4a72ae5c34c5ceaf19f3 /t/02-deps.t
parenta0cc11a5f9b60226a07054d6041cc45b4ea2221a (diff)
downloadbread-board-declare-8ad579f26a1c74d5685491df55b57e694e54e087.tar.gz
bread-board-declare-8ad579f26a1c74d5685491df55b57e694e54e087.zip
initial implementation
Diffstat (limited to 't/02-deps.t')
-rw-r--r--t/02-deps.t45
1 files changed, 45 insertions, 0 deletions
diff --git a/t/02-deps.t b/t/02-deps.t
new file mode 100644
index 0000000..73b3d4a
--- /dev/null
+++ b/t/02-deps.t
@@ -0,0 +1,45 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+{
+ package Baz;
+ use Moose;
+
+ has bar => (
+ is => 'ro',
+ isa => 'Str',
+ required => 1,
+ );
+}
+
+{
+ package Foo;
+ use Moose;
+ use MooseX::Bread::Board;
+
+ my $i = 0;
+ has bar => (
+ is => 'ro',
+ isa => 'Str',
+ block => sub { $i++ },
+ );
+
+ has baz => (
+ is => 'ro',
+ isa => 'Baz',
+ class => 'Baz',
+ dependencies => ['bar'],
+ );
+}
+
+{
+ my $foo = Foo->new;
+ my $baz = $foo->baz;
+ is($baz->bar, '0', "deps resolved correctly");
+ is($baz->bar, '0', "doesn't re-resolve, since Baz is a normal class");
+ is($foo->baz->bar, '1', "re-resolves since the baz attr isn't a singleton");
+}
+
+done_testing;