in reply to "Inline" module testing?

Hi,

I don't understand what you want

This is iffy  $INC{__PACKAGE__.".pm"} = 1 ; better is  $INC{ Module::Load::_to_file(__PACKAGE__) } = __FILE__;

I find this easier

#!/usr/bin/perl -- use strict; use warnings; MeMyselfTestSuite() unless caller ; exit 0; BEGIN { package MeMyself; use Module::Load qw/ /; use Data::Dump qw/ dd /; $INC{ Module::Load::_to_file( __PACKAGE__ ) } = __FILE__; sub import { dd( \@_ , [caller] ); } 1; } sub MeMyselfTestSuite { use Module::Load; load( 'MeMyself', 1,2,3,4 ); }

Replies are listed 'Best First'.
Re^2: "Inline" module testing?
by LanX (Saint) on Aug 15, 2017 at 00:59 UTC
    Thanks!

    > I don't understand what you want

    Maybe the wording "module testing" was to sloppy

    Real module testing requires a test suite, not a sub at the end of the file.

    I meant rather "module demonstration" or "proof of concept" testing, where module.pm and user.pl are packed into the same file, like when posting an example on perlmonks.

    Thank you for the interesting code, but it's significantly un-easier for my case, might help me in other occasions though.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!