Test::S...xporter(3)

πŸ“¦
version 1.302027 Β· 2 versions
, in fedora 43

πŸ’– Test::Stream::Exporter πŸ’–

hiii bestie, welcome to the User Contributed Perl Documentation page for Test::Stream::Exporter (yes, that's section 3, we're fancy like that) ✨


🚨 DEPRECATED 🚨

okay so first things first, and I need you to sit down for this: this whole distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow.

if you're trying to migrate, there's a conversion guide waiting for you at Test::Stream::Manual::ToTest2. go read it, it's giving ✨glow up✨.


🌸 DESCRIPTION 🌸

Test::Stream::Exporter is the internal implementation of some key features from Exporter::Declare. lowkey it's a much more powerful exporting tool than plain old Exporter. this package exists so that complicated export logic across Test::Stream and friends can be managed easily. it's giving main character energy for your namespace πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

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;

...;

πŸ‘‘ CONTROLLING IMPORTS πŸ‘‘

πŸŽ€ IMPORTING SUBS WITH ALTERNATE NAMES πŸŽ€

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 cap, it just won't see them. πŸ™ˆ

the rename syntax is borrowed from Exporter::Declare, which borrowed it from Sub::Exporter. it's a whole lineage, iconic honestly.

use Some::Exporter an_export => {-as => 'new_name'}, other_export => {-as => 'other_name'};

you can also prefix and/or postfix to the names:

use Some::Exporter an_export => {-preifx => 'my_', postfix '_tool'};

# Now use it:
my_an_export_tool(...);

(yes, -preifx is spelled exactly like that in the source. not my typo, not your typo, we leave it alone πŸ’…)


🌈 IMPORTING ALL SUBS 🌈

you can use -all to import ALL subs exported by a module. all of them. every last one. periodt.

use Some::Exporter '-all';

and it combines with aliasing, because why wouldn't it:

use Some::Exporter '-all', foo => { -as => 'my_foo' };

in this example "foo" will be imported as 'my_foo', and all the other subs will be imported with their original names. order is not important here, so don't stress about it bestie 🫢


⭐ IMPORTING DEFAULTS PLUS ⭐

use -default to import all the default subs, and then list the others you want on top of that:

use Some::Exporter '-default', qw/and_this and_that/;

and if you want all the defaults AND to rename one or more of them:

use Some::Exporter '-default', foo => { -as => 'my_foo' };

in this example foo() will be imported as my_foo(). all the other defaults also get imported, just with their original names. order is not important here either, so breathe 🧚


πŸ’œ CUSTOMIZING AN IMPORT METHOD πŸ’œ

sometimes you need to make a custom import method, but you still want to use the exporter tool to manage your exports. here's 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;

πŸ“ EXPORTS πŸ“

πŸ’« DEFAULT πŸ’«

METHODS

  • $class->import(@list) β€” your class needs this one to function as an exporter. it's the whole vibe, don't skip it.

FUNCTIONS

Note: all of thease are removed by default when you run "no Test::Stream::Exporter;" β€” so don't go looking for them afterwards πŸ™ˆ
  • export NAME => sub { ... }, default_export NAME => sub { ... } β€” these are how you define exports that might not actually be subs in the current package. anonymous subs, but make it official ✨
  • exports qw/foo bar baz/, default_exports qw/foo bar baz/ β€” these let you export package subs en masse. bulk export, we love efficiency πŸ’…

🌸 OTHER AVAILABLE EXPORTS 🌸

METHODS

  • $class->export_to($dest), $class->export_to($dest, \@symbols) β€” export from the exporter class into the $dest package. the seconond argument is optional, and if you omit it, the default export list gets used instead. if you do pass it, it has to be an arrayref full of export names.

FUNCTIONS

Note: all of thease are removed by default when you run "no Test::Stream::Exporter;" β€” same deal as before 🫢
  • export_from($from, $to), export_from($from, $to, \@symbols) β€” this will export all the specified symbols from the $from package over to the $to package. moving them across the board like a lil relocation πŸ’–

πŸ”₯ SOURCE πŸ”₯

the source code repository for Test::Stream lives at http://github.com/Test-More/Test-Stream/ β€” go peek, it's lowkey iconic.


πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org>

🌈 AUTHORS 🌈

  • Chad Granum <exodist@cpan.org>
  • Kent Fredric <kentnl@cpan.org>

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://dev.perl.org/licenses/


okay bestie that's the whole page, you ate it πŸŽ€ mwah πŸ’‹ this was Test::S...xporter(3), perl v5.42.0, dated 2025-07-25 β€” signing off, stay slaying in your namespace πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from