summaryrefslogtreecommitdiffstats
path: root/t/02-deps.t
diff options
context:
space:
mode:
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;