Guest User

Untitled

a guest
Jun 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. use 5.024;
  2. use Test::Most;
  3.  
  4. package C {
  5. use Moo::Role;
  6. has dir => ( is => 'ro', required => 1 );
  7. has file => ( is => 'ro', default => sub { sprintf '%s/%s.pm.ep' => $_[0]->dir, ref($_[0]) =~ s/::/\//gr } );
  8. };
  9.  
  10. package A {
  11. use Moo;
  12. with 'C';
  13. };
  14.  
  15. package B {
  16. use Moo;
  17. with 'C';
  18. };
  19.  
  20. package D::E {
  21. use Moo;
  22. with 'C';
  23. };
  24.  
  25. subtest 'template_file is different per role' => sub {
  26. cmp_deeply(
  27. new_ok( A => [ dir => '/tmp' ] ),
  28. methods( file => '/tmp/A.pm.ep' ),
  29. 'get the correct template',
  30. );
  31.  
  32. cmp_deeply(
  33. new_ok( B => [ dir => '/tmp' ] ),
  34. methods( file => '/tmp/B.pm.ep' ),
  35. 'get the correct template',
  36. );
  37.  
  38. cmp_deeply(
  39. new_ok( 'D::E' => [ dir => '/tmp' ] ),
  40. methods( file => '/tmp/D/E.pm.ep' ),
  41. 'get the correct template',
  42. );
  43. };
  44.  
  45. done_testing;
Add Comment
Please, Sign In to add comment