From: Toby Inkster Date: Thu, 27 Jun 2013 14:23:27 +0000 (+0100) Subject: failing test for method conflicts during role composition (argh) X-Git-Tag: v1.003000~26 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e75127f5f7fab408b48673edb590d34fa4024b55;p=gitmo%2FRole-Tiny.git failing test for method conflicts during role composition (argh) --- diff --git a/t/method-conflicts.t b/t/method-conflicts.t new file mode 100644 index 0000000..7487f88 --- /dev/null +++ b/t/method-conflicts.t @@ -0,0 +1,54 @@ +use strict; +use warnings; + +use Test::More; + +{ + package Local::R1; + use Role::Tiny; + sub method { 1 }; +} + +{ + package Local::R2; + use Role::Tiny; + sub method { 2 }; +} + +# Need to use stringy eval, so not Test::Fatal +$@ = undef; +ok( + !eval(q{ + package Local::C1; + use Role::Tiny::With; + with qw(Local::R1 Local::R2); + 1; + }), + 'method conflict dies', +); + +like( + $@, + qr{^Due to a method name conflict between roles 'Local::R. and Local::R.', the method 'method' must be implemented by 'Local::C1'}, + '... with correct error message', +); + +$@ = undef; +ok( + eval(q{ + package Local::C2; + use Role::Tiny::With; + with qw(Local::R1 Local::R2); + sub method { 3 }; + 1; + }), + '... but can be resolved', +); + +is( + "Local::C2"->method, + 3, + "... which works properly", +); + +done_testing; \ No newline at end of file