Explicitly return the DOES coderef if we install it
[gitmo/Role-Tiny.git] / t / role-basic / lib / MyTests.pm
CommitLineData
8e50c419 1package MyTests;
2
3use strict;
4use warnings;
5
6use Test::More ();
7use Try::Tiny;
8
9sub import {
10 my $class = shift;
11 my $caller = caller;
12
13 no strict 'refs';
14 *{"${caller}::exception"} = \&exception;
15 local $" = ", ";
16 use Data::Dumper;
17 $Data::Dumper::Terse = 1;
18 @_ = Dumper(@_);
19 eval <<" END";
20 package $caller;
21 no strict;
22 use Test::More @_;
23 END
24 die $@ if $@;
25}
26
27sub exception (&) {
28 my ($code) = @_;
29
30 return try {
31 $code->();
32 return undef;
33 }
34 catch {
35 return $_ if $_;
36
37 my $problem = defined $_ ? 'false' : 'undef';
38 Carp::confess("$problem exception caught by Test::Fatal::exception");
39 };
40}
41
421;