Test::Stream::Exporter - Declarative exporter for Test::Stream and friends.
This is an experimental release! Test-Stream, and all its components are still in an experimental phase. This dist has been released to cpan in order to allow testers and early adopters the chance to write experimental new tools with it, or to add experimental support for it into old tools.
PLEASE DO NOT COMPLETELY CONVERT OLD TOOLS YET. This experimental release is very likely to see a lot of code churn. API's may break at any time. Test-Stream should NOT be depended on by any toolchain level tools until the experimental phase is over.
Test::Stream::Exporter is an internal implementation of some key features from Exporter::Declare. This is a much more powerful exporting tool than Exporter. This package is used to easily manage complicated EXPORT logic across Test::Stream and friends.
use Test::Stream::Exporter; # Export some named subs from the package default_exports qw/foo bar baz/; exports qw/fluxx buxx suxx/; # Export some anonymous subs under specific names. export some_tool => sub { ... }; default_export another_tool => sub { ... }; # Call this when you are done providing exports in order to cleanup your # namespace. no Test::Stream::Exporter; ...;
Note: If you import Test::Stream::Exporter functions under alternative names, no Test::Stream::Exporter; will not find and remove them like it normally would.
no Test::Stream::Exporter;
When you specify a sub to import you may postfix an equal sign and a name under which it should be imported. In a qw quote you cannot use spaces as that would split it into 3 distinct strings. However with individual quoting spaces are allowed.
qw
use Some::Exporter qw/an_export=new_name other_export=other_name/;
or
use Some::Exporter 'an_export = new_name', 'other_export = other_name';
Sometimes you need to make a custom import method, but you still want to use the exporter tool to manage exports. here is how you do it:
use Test::Stream::Exporter qw/export exports export_from/; export foo => sub { 'foo' }; export qw/bar baz/; sub import { my $class = shift; my @exports = @_; # Do whatever you need to ... # Now go ahead and do the exporting with your list my $caller = caller; export_from($class, $caller, \@exports); } # This will cleanup the namespace, including 'export_from', do you need to # do it AFTER your import method. no Test::Stream::Exporter; sub bar { 'bar' } sub baz { 'baz' } 1;
Your class needs this to function as an exporter.
Note: All of thease are removed by default when you run no Test::Stream::Exporter;
These are used to define exports that may not actually be subs in the current package.
These let you export package subs en mass.
Export from the exporter class into the $dest package. The seconond argument is optional, if it is omitted the default export list will be used. The second argument must be an arrayref with export names.
$dest
This will export all the specified symbols from the $from package to the $to package.
$from
$to
The source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/.
Copyright 2015 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install Test::Stream, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Stream
CPAN shell
perl -MCPAN -e shell install Test::Stream
For more information on module installation, please visit the detailed CPAN module installation guide.