Modulino-Demo

 view release on metacpan or  search on metacpan

lib/Modulino/Test.pm  view on Meta::CPAN

use v5.14;

package Modulino::Test;
use strict;
use utf8;

use warnings;

our $VERSION = '1.006';

UNITCHECK {
sub _running_under_tester {
	!! $ENV{CPANTEST}
	}

sub _running_as_app {
	defined scalar caller
	}

my $method = do {
	   if( _running_under_tester()    ) { 'test' } # testing
	elsif( _running_as_app()          ) { 'run'  } # running the application
	else                                { undef  } # everything else
	};

__PACKAGE__->$method(@ARGV) if defined $method;
}

=encoding utf8

=head1 NAME

Modulino::Test - A demonstration of module ideas

=head1 SYNOPSIS

This module isn't meant for use. It's an example of the modulino idea
with an additional branch to recognize test situations then run as a
test file.

=head1 DESCRIPTION

=over 4

=item run

=cut

sub run {
	say "Running as program";
	}

sub _test_run {
	require Test::More;

	Test::More::pass();
	Test::More::pass();

	SKIP: {
		Test::More::skip( "These tests don't work", 2 );
		Test::More::fail();
		Test::More::fail();
		}
	}

=back

=head2 Testing

=over 4



( run in 1.409 second using v1.01-cache-2.11-cpan-39bf76dae61 )