From: Robert 'phaylon' Sedlacek Date: Fri, 10 Aug 2007 17:16:07 +0000 (+0000) Subject: search_class_by_role tests added X-Git-Tag: 0_25~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c1d8a982d0c480e27d948efe53ea2ce020f3fa6;p=gitmo%2FMoose.git search_class_by_role tests added --- diff --git a/t/400_moose_util.t b/t/400_moose_util.t index 247617e..d3fb650 100644 --- a/t/400_moose_util.t +++ b/t/400_moose_util.t @@ -1,6 +1,6 @@ #!/usr/bin/env perl -use Test::More tests => 9; +use Test::More tests => 13; use strict; use warnings; @@ -53,3 +53,38 @@ ok(! Moose::Util::does_role(undef,'Foo')); ok(! Moose::Util::does_role(1,'Foo')); +# +# search_class_by_role tests +# +BEGIN { Moose::Util->import(qw( search_class_by_role )) } +my $t_pfx = 'search_class_by_role: '; + +{ package SCBR::Role; + use Moose::Role; +} + +{ package SCBR::A; + use Moose; +} +is search_class_by_role('SCBR::A', 'SCBR::Role'), undef, $t_pfx . 'not found role returns undef'; + +{ package SCBR::B; + use Moose; + extends 'SCBR::A'; + with 'SCBR::Role'; +} +is search_class_by_role('SCBR::B', 'SCBR::Role'), 'SCBR::B', $t_pfx . 'class itself returned if it does role'; + +{ package SCBR::C; + use Moose; + extends 'SCBR::B'; +} +is search_class_by_role('SCBR::C', 'SCBR::Role'), 'SCBR::B', $t_pfx . 'nearest class doing role returned'; + +{ package SCBR::D; + use Moose; + extends 'SCBR::C'; + with 'SCBR::Role'; +} +is search_class_by_role('SCBR::D', 'SCBR::Role'), 'SCBR::D', $t_pfx . 'nearest class being direct class returned'; +