Help language development. Donate to The Perl Foundation

FindBin cpan:LEMBARK last updated on 2020-01-21

t/01-FindBin.rakutest
use v6.d;
use lib $*PROGRAM.parent(2).add( 'lib' ).absolute;

use Test;


# use alt regex to test for method via '~' or something 
# similar. allows symlinking "dd-<madness>~<method>.t" to 
# quickly iterate whether there is, obviously, any method
# in your madness.

( $*PROGRAM-NAME.IO.basename ~~ m{^ (\d+ '-')? (.+) '.' (t|rakutest) $} )
or bail-out 'Unable to parse test name: ' ~ $*PROGRAM-NAME;

my $madness = $1.subst( '-', '::', :g );

note "# Madness: '$madness' ($*PROGRAM-NAME)" ;

use-ok $madness;

lives-ok 
{
    require ::( $madness );

    my $found   = ::( $madness ).^name;

    is $found, $madness, "Package '$found' installed ($madness).";
},
"require '$madness' survives.";

done-testing;