1#!/usr/bin/perl 2 3use strict; 4use warnings; 5use lib 't/lib'; 6use GenErrorRegex qw< badval_error >; 7 8use Test::More; 9use Test::Exception; 10 11 12# This may not be possible. I'm not sure that Role::Basic and Mouse are going to play nice 13# together, and I'm not even sure it's a viable use case. That is, if you're using 14# Method::Signatures, you're already getting Mouse, and, if you're already getting Mouse, why use 15# Role::Basic? Role::Basic's doco itself says that it's designed for people who don't want Mouse 16# (or Moose), and, if you don't want Mouse, you might not want to use Method::Signatures, since that 17# brings in Mouse whether you like it or not (assuming you're doing type checking, but then, if 18# you're not doing type checking, you wouldn't be caring about Role::Basic interaction). 19# 20# So if we decide we want to pursue this, it may be possible by working with Ovid and creating a 21# Mouse subtype to check Role::Basic roles, but in the meantime, I'm just marking this all TODO. 22TODO: { 23 local $TODO = "Compatibility with Role::Basic unimplemented"; 24 25 26{ package Foo::Bar; sub new { bless {}, __PACKAGE__; } } 27 28SKIP: 29{ 30 eval "use Role::Basic ()" or skip "Role::Basic required for testing basic roles", 2; 31 32 require BasicRoleTest; 33 use Method::Signatures; 34 35 my $basic = WithBasicRole->new; 36 my $foobar = Foo::Bar->new; 37 38 39 func basicy (BasicRole $foo) {} 40 41 42 # positive test 43 lives_ok { basicy($basic) } 'Basic role passes okay'; 44 45 # negative test 46 throws_ok { basicy($foobar) } badval_error(undef, foo => BasicRole => $foobar, 'basicy'), 47 'Basic role fails when appropriate'; 48} 49 50} 51 52 53done_testing; 54