Mite

 view release on metacpan or  search on metacpan

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

{
    package Test::Mite;

    use feature ':5.10';
    use strict;
    use warnings;

    use parent 'Fennec';
    use Path::Tiny;

    # func, not a method, to avoid altering @_
    sub import {
        # Turn on strict, warnings and 5.10 features
        strict->import;
        warnings->import;
        require feature;
        feature->import(":5.10");

        # Make everything in @INC absolute so we can chdir in tests
        @INC = map { path($_)->absolute->stringify } @INC;

        #push @_, test_sort => 'ordered';
        goto &Fennec::import;
    }

    # Export our extra mite testing functions.
    sub defaults {
        my $class = shift;
        my %params = $class->SUPER::defaults;

        push @{ $params{utils} },
          "Test::Mite::Functions",
          "Test::Deep",
          "Test::FailWarnings";

        return %params;
    }

    # Test with and without Class::XSAccessor.
    sub after_import {
        my ($class, $info) = (shift, @_);
        return unless $info->{meta}{with_recommends};

        # Test the pure Perl implementation.
        $info->{layer}->add_case(
            [$info->{importer}, __FILE__, __LINE__ + 1],
            case_pure_perl => sub {
                $ENV{MITE_PURE_PERL} = 1;
            },
        );

        # Test with Class::XSAccessor, if available.
        $info->{layer}->add_case(
            [$info->{importer}, __FILE__, __LINE__ + 1],
            case_xs => sub {
                $ENV{MITE_PURE_PERL} = 0;
            },
        ) if eval { require Class::XSAccessor };
    }
}


# Because of the way Fennec works, it's easier to put
# all our extra functions into their on class.
{
    package Test::Mite::Functions;

    use feature ':5.10';
    use strict;
    use warnings;

    use parent 'Exporter';
    our @EXPORT = qw(
        mite_compile mite_load



( run in 1.052 second using v1.01-cache-2.11-cpan-5511b514fd6 )