use FindBin; use Test::More tests => 3; use Test::Exception; dies_ok { 'DupEventChecker'->new } 'dir_name not provided'; my $checker = 'DupEventChecker'->new(dir_name => $FindBin::Bin); isa_ok $checker, 'DupEventChecker'; my ($itself) = grep { 0 <= index $0, $_ } $checker->dir->read; ok $itself, 'test script found'; #### has 'dir' => ( is => 'ro', isa => 'IO::Dir', required => 1 ); around BUILDARGS => sub { $_ = shift for my ($orig, $class); my %args = @_; die 'required dir missing' unless exists $args{dir}; return $class->$orig(dir => 'IO::Dir'->new($args{dir})) } #### #!/usr/bin/perl use warnings; use strict; { package DupEventChecker; use IO::Dir; use Moose; use namespace::autoclean; has 'dir' => ( is => 'ro', isa => 'Str', required => 1 ); has '_dir' => ( is => 'ro', isa => 'IO::Dir', lazy => 1, builder => '_build_dir', handles => { read_dir => 'read' }, init_arg => undef, ); sub _build_dir { 'IO::Dir'->new(shift->dir) } __PACKAGE__->meta->make_immutable; } use FindBin; use Test::More tests => 3; use Test::Exception; dies_ok { 'DupEventChecker'->new } 'dir not provided'; my $checker = 'DupEventChecker'->new(dir => $FindBin::Bin); isa_ok $checker, 'DupEventChecker'; my $itself = grep $0 =~ m{(?:^|/)\Q$_\E$}x, $checker->read_dir; is $itself, 1, 'test script found'; #### ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,