perl5i

 view release on metacpan or  search on metacpan

lib/perl5i/2.pm  view on Meta::CPAN

    return CORE::stat($_[0]) if wantarray;
    return File::stat::stat(@_);
}

sub lstat {
    return CORE::lstat($_[0]) if wantarray;
    return File::stat::lstat(@_);
}


sub capture(&;@) {
    my($code, %opts) = @_;

    # valid options
    state $valid_options = { map { $_ => 1 } qw(merge tee) };

    for my $key (keys %opts) {
        croak "$key is not a valid option to capture()" unless $valid_options->{$key};
    }

    my $opts = join "/", sort { $a cmp $b } grep { $opts{$_} } keys %opts;

t/lib/Test/perl5i.pm  view on Meta::CPAN


use Test::More ();

use base qw(Exporter);
our @EXPORT = qw(throws_ok dies_ok lives_ok);

# This is a replacement for Test::Exception which messes with caller()
# and screws up Carp.
# See http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2010-03/msg00520.html
# Could use Test::Exception::LessClever but that's not testing on Windows
sub throws_ok(&$;$) {
    my($code, $regex, $name) = @_;

    my $tb = Test::More->builder;

    my $lived = eval { $code->(); 1 };
    if( $lived ) {
        $tb->ok(0, $name);
        $tb->diag("It lived when it should have died");
    }
    return $tb->like($@, $regex, $name);
}

sub dies_ok(&;$) {
    my($code, $name) = @_;

    my $lived = eval { $code->(); 1 };

    my $tb = Test::More->builder;
    $tb->ok( !$lived, $name );
}

sub lives_ok(&;$) {
    my($code, $name) = @_;
    my $lived = eval { $code->(); 1 };

    my $tb = Test::More->builder;
    $tb->ok( $lived, $name );
}

1;



( run in 0.747 second using v1.01-cache-2.11-cpan-49f99fa48dc )