summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-10-03 18:59:26 -0500
committerJesse Luehrs <doy@tozt.net>2011-10-03 18:59:26 -0500
commit6c0a0188bd28d2bb43dfcf797a4e04bdbc84b0e9 (patch)
tree511990057dabdf17a0893ec1d78518283e2e661b /t
parent2e5208c7f0127df78b3ebc64f00bd3d0d1a242eb (diff)
downloadbread-board-declare-6c0a0188bd28d2bb43dfcf797a4e04bdbc84b0e9.tar.gz
bread-board-declare-6c0a0188bd28d2bb43dfcf797a4e04bdbc84b0e9.zip
add test for inferring being fulfilled by subclasses
Diffstat (limited to 't')
-rw-r--r--t/infer-subclasses.t100
1 files changed, 100 insertions, 0 deletions
diff --git a/t/infer-subclasses.t b/t/infer-subclasses.t
new file mode 100644
index 0000000..b50b909
--- /dev/null
+++ b/t/infer-subclasses.t
@@ -0,0 +1,100 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+
+{
+ package NonMoose;
+ sub new { bless { data => $_[0] }, shift }
+}
+
+{
+ package Foo;
+ use Moose;
+
+ has non_moose => (
+ is => 'ro',
+ isa => 'NonMoose',
+ required => 1,
+ );
+}
+
+{
+ package Bar;
+ use Moose;
+
+ has foo => (
+ is => 'ro',
+ isa => 'Foo',
+ required => 1,
+ );
+}
+
+{
+ package Container;
+ use Moose;
+ use Bread::Board::Declare;
+
+ has non_moose => (
+ is => 'ro',
+ isa => 'NonMoose',
+ block => sub { NonMoose->new("blah") },
+ );
+
+ has foo => (
+ is => 'ro',
+ isa => 'Foo',
+ dependencies => ['non_moose'],
+ );
+
+ has bar => (
+ is => 'ro',
+ isa => 'Bar',
+ infer => 1,
+ );
+}
+
+{
+ my $c = Container->new;
+ my $bar = $c->bar;
+ isa_ok($bar->foo->non_moose, 'NonMoose');
+}
+
+{
+ package Foo::Sub;
+ use Moose;
+
+ extends 'Foo';
+}
+
+{
+ package Container2;
+ use Moose;
+ use Bread::Board::Declare;
+
+ has non_moose => (
+ is => 'ro',
+ isa => 'NonMoose',
+ block => sub { NonMoose->new("blah") },
+ );
+
+ has foo => (
+ is => 'ro',
+ isa => 'Foo::Sub',
+ dependencies => ['non_moose'],
+ );
+
+ has bar => (
+ is => 'ro',
+ isa => 'Bar',
+ infer => 1,
+ );
+}
+
+{
+ my $c = Container2->new;
+ my $bar = $c->bar;
+ isa_ok($bar->foo->non_moose, 'NonMoose');
+}
+
+done_testing;