1#!/usr/bin/perl 2 3use strict; 4use warnings; 5 6use Test::More; 7use Test::Moose; 8 9use Bread::Board; 10 11{ 12 package My::Foo; 13 use Moose; 14 15 has 'bar' => ( 16 is => 'ro', 17 isa => 'My::Bar', 18 required => 1 19 ); 20 21 package My::Bar; 22 use Moose; 23 24 has 'foo' => ( 25 is => 'ro', 26 isa => 'My::Foo', 27 required => 1 28 ); 29 30} 31 32{ 33 my $c = container 'MyTestContainer' => as { 34 typemap 'My::Foo' => infer; 35 }; 36 37 ok($c->has_type_mapping_for('My::Foo'), '... have a type mapping for My::Foo'); 38 39 { 40 my $foo = $c->resolve( type => 'My::Foo' ); 41 isa_ok($foo, 'My::Foo'); 42 isa_ok($foo->bar, 'My::Bar'); 43 } 44 45 { 46 my $bar = $c->resolve( service => 'type:My::Bar' ); 47 isa_ok($bar, 'My::Bar'); 48 isa_ok($bar->foo, 'My::Foo'); 49 } 50} 51 52done_testing; 53