Help language development. Donate to The Perl Foundation

Test::META cpan:JSTOWE last updated on 2019-03-04


use v6;

use Test;

use META6;
use Test::META;

diag "the following may make some diagnostics from the module itself";

$Test::META::TESTING = True;

lives-ok { Test::META::get-meta() }, "get-meta";

    # non-existent but specified implicitly;
    my $*META-FILE = "flurblsleb";
    is Test::META::get-meta(), $*META-FILE, 'gen-meta respects $*META-FILE';
    my @*META-CANDIDATES = <flurblsleb wiobeke>/
    ok !Test::META::get-meta().defined, 'get-meta() uses @*META-CANDIDATES';

    my $*DIST-DIR = $*PROGRAM.parent.child('data');
    my @*META-CANDIDATES = <>;

    ok my $meta = Test::META::get-meta(), "get-meta() with existing file";
    ok $meta.e, "file returned exists";
    is $meta.basename, '', "and the file we expected";


    nok Test::META::check-mandatory(, "check-mandatory on empty META";
    my $good = =>"6"), version =>"0.0.1"), description => "Test thing", name => "Test::META");

    ok Test::META::check-mandatory($good), "check-mandatory with all defined";

    ok Test::META::check-provides(, "check-provides on empty META";
    nok Test::META::check-provides( => ( 'HH::GG' => 'lib/Boodle',))), "check-provides with bogus provides";
    nok Test::META::check-provides( => ('Test::META' => '/lib/Test/',))), "check-provides with my own files but absolute path";
    ok Test::META::check-provides( => ('Test::META' => 'lib/Test/',))), "check-provides with my own files";
    ok Test::META::check-authors(, "check-authors no authors";
    ok Test::META::check-authors( => ["A.U. Thor"])), "check-authors with 'authors'";
    ok Test::META::check-authors( => ["A.U. Thor"], author => "A.U. Thor")), "check-authors with 'authors' and 'author'";
    nok Test::META::check-authors( => "A.U. Thor")), "check-authors with 'author' only";
    ok Test::META::check-name( => "Test::META")), "check-name with good name";
    nok Test::META::check-name( => "Test-META")), "check-name with bad name";
    ok Test::META::check-name( => "Test-META"), :relaxed-name), "check-name with bad name but :relaxed-name";
    ok Test::META::check-license( => "Artistic-2.0")), "check-license with good license name";
    nok Test::META::check-license( => "Artistic")), "check-license with bad license name";
    ok Test::META::check-license(
        license => "My Super Cool License", support =>''))

    ), "check-license with bad license name - but a URL was supplied";

subtest {
    nok Test::META::check-version(, "check-version with no version";
    nok Test::META::check-version( =>"*"))), "check-version with plain '*'";
    nok Test::META::check-version( =>"1.1.*"))), "check-version with embedded '*'";
    ok Test::META::check-version( =>'0.0.1'))), "check-version with a good version";

}, "check-version";

subtest {
    nok Test::META::check-sources( => '[email protected]:jonathanstowe/Test-META.git')), "not a valid URI";
    nok Test::META::check-sources( => 'git://')), "git URI must end in git";
    ok Test::META::check-sources( => '')), "non-git URI needn't must end in git";

}, "check-sources";

# vim: expandtab shiftwidth=4 ft=perl6