Created
June 27, 2018 13:47
-
-
Save dallaylaen/18fdc07147fb8840b9696fcb82cbe603 to your computer and use it in GitHub Desktop.
require a script w/o side effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
return 1 if caller; # before parsing args, output, input etc | |
print foo(); # side effect! | |
sub foo { | |
return 42; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Test::More; | |
use lib "."; | |
require "foo.pl"; | |
is foo(), 42, "Foo is fine"; | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment