The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Stream::Util - Tools used by Test::Stream and friends.

EXPERIMENTAL CODE WARNING

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.

DESCRIPTION

Collection of tools used by Test::Stream and friends.

EXPORTS

($success, $error) = try { ... }

Eval the codeblock, return success or failure, and the error message. This code protects $@ and $!, they will be restored by the end of the run. This code also temporarily blocks $SIG{DIE} handlers.

protect { ... }

Similar to try, except that it does not catch exceptions. The idea here is to protect $@ and $! from changes. $@ and $! will be restored to whatever they were before the run so long as it is successful. If the run fails $! will still be restored, but $@ will contain the exception being thrown.

USE_THREADS

Returns true if threads are enabled, false if they are not.

get_tid

This will return the id of the current thread when threads are enabled, otherwise it returns 0.

$XSUB = USE_XS($VERSION, $XSUB_NAME);

This function takes 2 arguments, a minimum version, and the name of an xsub provided by Test::Stream::XS. If Test::Stream::XS is installed, and at or above the specified version, the requested xsub will be returned. If the version is too low, or Test::Stream::XS is not installed, undef is returned.

This is useful for decided between a pure-perl sub and an xs sub:

    use Test::Stream::Util qw/USE_XS/;

    *some_sub = USE_XS('1.111111', 'some_sub_xs') || \&some_sub_pp;

SOURCE

The source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

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

COPYRIGHT

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