Skip to content

Commit

Permalink
test check_implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
kfly8 committed Feb 27, 2021
1 parent ba8ec8f commit a4a64e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/Boundary.pm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ sub apply_interfaces_to_package {

sub check_implementations {
my ($class, $impl, @interfaces) = @_;
my %interface_map = %{$INFO{$impl}{interface_map}||{}};
return if !$INFO{$impl};
my %interface_map = %{$INFO{$impl}{interface_map}};
for (@interfaces) {
return if !$interface_map{$_}
}
Expand Down
23 changes: 23 additions & 0 deletions t/check_implementations.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use strict;
use warnings;
use lib 't/lib';
use Test::More;

use Boundary ();

ok(!Boundary->check_implementations('Foo', 'IFoo'), 'IFoo is not yet applied as an interface of Foo.');

ok(!Boundary->check_implementations('Foo', 'IFoo'), 'IFoo is not yet applied as an interface of Foo.');

{
package Foo;
sub hello;
}

Boundary->apply_interfaces_to_package('Foo', 'IFoo');

ok(Boundary->check_implementations('Foo', 'IFoo'), 'Foo is an implementation of IFoo');

ok(!Boundary->check_implementations('Foo', 'IBar'), 'Foo is not an implementation of IBar');

done_testing;

0 comments on commit a4a64e5

Please sign in to comment.