1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Test::Exception::LessClever;
BEGIN {
use_ok( 'Devel::Declare::Parser::Sublike', 'sl' );
use_ok( 'Devel::Declare::Parser::Codeblock', 'cb' );
use_ok( 'Devel::Declare::Parser::Method', 'mth' );
Devel::Declare::Interface::enhance( 'main', $_->[0], $_->[1] )
for [ 'sl', 'sublike' ],
[ 'cb', 'codeblock' ],
[ 'mth', 'method' ],
[ 'beg', 'begin' ];
}
sub
sl {
$_[-1]->();
}
sub cb {
$_[-1]->();
}
sub mth {
$_[-1]->( 'self' );
}
sub beg {
$_[-1]->();
};
our %ran;
sl a {
$ran{sl}++;
}
sl {
$ran{sl}++;
}
our $BEGIN;
BEGIN { $BEGIN = 1 };
$BEGIN = 0;
ok( !$BEGIN, "reset begin" );
beg( sub { $ran{beg}++; ok( $BEGIN, "In Begin" )});
ok( $ran{beg}, "ran beg" );
cb {
$ran{cd}++;
}
mth a {
is( $self, 'self', "got self" );
$ran{mth}++;
}
is( $ran{sl}, 2, "ran sl twice" );
ok( $ran{cd}, "ran cd" );
ok( $ran{mth}, "ran mth" );
done_testing();
|