Test-Output-1.031/000755 000765 000024 00000000000 13067023757 014203 5ustar00brianstaff000000 000000 Test-Output-1.031/Changes000644 000765 000024 00000006600 13067023736 015475 0ustar00brianstaff000000 000000 Revision history for Perl module Test::Output 1.031 2017-03-29T21:30:57Z * Get rid of Sub::Exporter. That module has nice features that this module doesn't use and the prereq is causing problems with CPAN Testers. CPAN Grep didn't show anyone using advanced features for exports. 1.03 - 2014-01-03 * Get rid of MYMETA 1.02_01 - 2013-12-17 * Get rid of MYMETA 1.02 - 2013-07-08 * Bump to stable release 1.01_02 - 2012-07-19 * Remove the ::Tie stuff. It should be fully Capture::Tiny now. 1.01_01 - 2012-05-14 * David Golden re-did everything with Capture::Tiny to get around the odd output paths that we coudn't handle with a tie. 1.01 - 2011-04-22 * Bump to a full release. This fixes the tests that failed in the new 5.14 regex stringification 0.16_03 - 2010-10-25 * Fix cat-o with handling $, 0.16_02 - 2010-10-19 * Update tests with hardcoded regex stringification for Perl's new (?^:) stuff 0.16_01 - 2009-06-09 * Added META_MERGE features from chorny 0.13 - 2009-03-08 * brian d foy (bdfoy@cpan.org) is the new maintainer * Updated docs for source code location, license, etc 0.12 - 2008-10-25 * Repacking to remove OS X extended attribute files that were causing tests to fail. 0.11 2008-21-10 * Fixes for STDERR handling under Perl 5.6. Thanks to brian d foy for the patch with tests. 0.10 2005-18-07 * Migrated from Exporter to Sub::Exporter 0.09 2005-09-11 * New version of Test::Tester added a depth test which was causing tests to fail. Thanks to neildp for the patch. * Fixed warning messages during perl Makefile.PL caused by Test::Tester not being loaded first. 0.08 2005-19-07 * Supressed most warnings caused by newer versions of Test::Tester 0.07 2005-26-03 * Added methods: combined_is, combined_isnt, combined_like and combined_unlike. This combine STDOUT and STDERR into one filehandle and capture their output for testing. 0.06 2005-07-03 * Applied patch from David Wheeler to support code blocks within tests as well as coderefs. 0.05 2005-04-03 * Added chromatic's patch fixing diag messages printing even when tests pass. * Updated stdout_unlike.t to test for success. * Updated all tests for successful tests to include diag => ''. 0.04 2005-02-03 * Added methods: output_like, output_unlike * Moved output_from stdout_from and stderr_from out of @EXPORT and into @EXPORT_OK. * Reworked diag messages for output_is and output_isnt to only show the output that doesn't match. * replaced "comment" with "description" * More tests * Much refactoring 0.03 2005-16-02 * Reworked entire POD. Thanks to rjbs for his suggestions. * Additional POD fixes (date to data thanks to everyone who caught that). * New methods: stderr_like, stderr_unlike, stdout_like, stdout_unlike * Updated README from the default one created by Module::Starter. * Moved private methods _err,_out, and _errandout to stderr_from stdout_from and output_from respectively. Allowing access from the test file. Thanks to rjbs for this suggestion. 0.02 2005-12-02 * New methods: output_isnt, stderr_inst, stdout_isnt * Removed requirement for Filehandle * Removed errant leftover Test::Builder::Tester::Color from tests * Migrated all tests to Test::Tester (Test::Tester now a prereq) 0.01 2005-12-02 * First version, released on an unsuspecting world. Test-Output-1.031/INSTALL.SKIP000644 000765 000024 00000000156 13067023736 016000 0ustar00brianstaff000000 000000 README\.pod README.* # things that might be in local directories after fooling # around with them \.DS_Store Test-Output-1.031/lib/000755 000765 000024 00000000000 13067023751 014743 5ustar00brianstaff000000 000000 Test-Output-1.031/LICENSE000644 000765 000024 00000017403 13067023736 015212 0ustar00brianstaff000000 000000 The Test::Output module is licensed under the same terms as perl itself, under the Artistic License 2.0. Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. http://www.perlfoundation.org/artistic_license_2_0 Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation Test-Output-1.031/Makefile.PL000644 000765 000024 00000005372 13067023736 016161 0ustar00brianstaff000000 000000 package Test::Output; use strict; use warnings; =encoding utf8 =head1 The build file for Test::Output This build file is a modulino; it works as both a build script and a module. To build the distribution, run this file normally: % perl Makefile.PL But, it's more interesting than that. You can load it with C and call C to get the data structure it passes to C: my $package = require '/path/to/Makefile.PL'; my $arguments = $package->arguments; Note that C-ing a file makes an entry in C<%INC> for exactly that name. If you try to C another file with the same name, even from a different path, C thinks it has already loaded the file. As such, I recommend you always require the full path to the file. The return value of the C is a package name (in this case, the name of the main module. Use that to call the C method. Even if this distribution needs a higher version of Perl, this bit only needs v5.8. You can play with the data structure with a primitive Perl. =cut use File::Spec::Functions qw(catfile); my $module = __PACKAGE__; ( my $dist = $module ) =~ s/::/-/g; my $github = 'https://github.com/briandfoy/test-output'; my $main_file = catfile( 'lib', split /::/, "$module.pm" ); my %WriteMakefile = ( 'MIN_PERL_VERSION' => '5.008', 'NAME' => $module, 'AUTHOR' => 'brian d foy ', 'ABSTRACT_FROM' => $main_file, 'VERSION_FROM' => $main_file, 'LICENSE' => 'perl', 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.64', 'File::Spec::Functions' => '0', }, 'BUILD_REQUIRES' => { }, 'TEST_REQUIRES' => { 'Test::More' => '0.94', 'Test::Tester' => '0.107', 'Test::More' => '0', }, 'PREREQ_PM' => { 'File::Temp' => '0.17', # needs :seekable 'Capture::Tiny' => '0.17', }, 'META_MERGE' => { 'meta-spec' => { version => 2 }, keywords => ['testing','STDOUT','STDERR'], resources => { repository => { type => 'git', url => "$github.git", web => $github, }, bugtracker => { web => "$github/issues", }, homepage => $github, }, }, clean => { FILES => "$dist-*" }, ); sub arguments { \%WriteMakefile } do_it() unless caller; sub do_it { require File::Spec; my $MM ='ExtUtils::MakeMaker'; my $MM_version = eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } || "$MM 6.64"; eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; eval "use Test::Manifest 1.21" if -e File::Spec->catfile( qw(t test_manifest) ); my $arguments = arguments(); my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; eval "require $minimum_perl;" or die $@; WriteMakefile( %$arguments ); } no warnings; __PACKAGE__; Test-Output-1.031/MANIFEST000644 000765 000024 00000001156 13067023760 015331 0ustar00brianstaff000000 000000 Changes INSTALL.SKIP lib/Test/Output.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.pod t/00.load.t t/binmode.t t/carp-5.6.t t/combined_is.t t/combined_isnt.t t/combined_like.t t/combined_unlike.t t/output_is.t t/output_isnt.t t/output_like.t t/output_unlike.t t/pod-coverage.t t/pod.t t/stderr_is.t t/stderr_isnt.t t/stderr_like.t t/stderr_unlike.t t/stdout_is.t t/stdout_isnt.t t/stdout_like.t t/stdout_unlike.t xt/changes.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Test-Output-1.031/MANIFEST.SKIP000644 000765 000024 00000001776 13067023736 016111 0ustar00brianstaff000000 000000 #!start included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP \.travis\.yml \.releaserc Test-.* TODO Test-Output-1.031/META.json000664 000765 000024 00000002766 13067023757 015641 0ustar00brianstaff000000 000000 { "abstract" : "Utilities to test STDOUT and STDERR messages.", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.140640", "keywords" : [ "testing", "STDOUT", "STDERR" ], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-Output", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.64", "File::Spec::Functions" : "0" } }, "runtime" : { "requires" : { "Capture::Tiny" : "0.17", "File::Temp" : "0.17", "perl" : "5.008" } }, "test" : { "requires" : { "Test::More" : "0", "Test::Tester" : "0.107" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/briandfoy/test-output/issues" }, "homepage" : "https://github.com/briandfoy/test-output", "repository" : { "type" : "git", "url" : "https://github.com/briandfoy/test-output.git", "web" : "https://github.com/briandfoy/test-output" } }, "version" : "1.031" } Test-Output-1.031/META.yml000664 000765 000024 00000001476 13067023755 015464 0ustar00brianstaff000000 000000 --- abstract: 'Utilities to test STDOUT and STDERR messages.' author: - 'brian d foy ' build_requires: Test::More: '0' Test::Tester: '0.107' configure_requires: ExtUtils::MakeMaker: '6.64' File::Spec::Functions: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.140640' keywords: - testing - STDOUT - STDERR license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-Output no_index: directory: - t - inc requires: Capture::Tiny: '0.17' File::Temp: '0.17' perl: '5.008' resources: bugtracker: https://github.com/briandfoy/test-output/issues homepage: https://github.com/briandfoy/test-output repository: https://github.com/briandfoy/test-output.git version: '1.031' Test-Output-1.031/README.pod000644 000765 000024 00000006064 13067023736 015647 0ustar00brianstaff000000 000000 =pod =encoding utf8 =head1 The Test::Output module This is the I for the L Perl module. You're probably looking at this because you don't know where else to find what you're looking for. Read this once and you might never have to read one again for any Perl module. =head2 Documentation To read about L, look at the embedded documentation in the module itself. Inside the distribution, you can format it with L: % perldoc lib/Test/Output.pm If you have already installed the module, you can specify the module name instead of the file location: % perldoc Test::Output You can read the documentation and inspect the meta data on one of the CPAN web interfaces, such as L or L: =over 4 =item * L =item * L =back The standard module documentation has example uses in the SYNOPSIS section, but you can also look in the I directory (if it's there), or look at the test files in I. =head2 Installation You can install this module with a CPAN client, which will resolve and install the dependencies: % cpan Test::Output % cpanm Test::Output You can also install directly from the distribution directory, which will also install the dependencies: % cpan . % cpanm . You could install just this module manually: % perl Makefile.PL % make % make test % make install You probably don't want to do that unless you're fiddling with the module and only want to run the tests without installing anything. =head2 Source location The meta data, such as the source repository and bug tracker, is in I or the I files it creates. You can find that on those CPAN web interfaces, but you can also look at files directly in the source repository: =over 4 =item * L =back If you find a problem, file a ticket in the L: =over 4 =item * L =back =head2 Getting help Although I'm happy to hear from module users in private email, that's the best way for me to forget to do something. Besides the issue trackers, you can find help at L or L, both of which have many competent Perlers who can answer your question, almost in real time. They might not know the particulars of this module, but they can help you diagnose your problem. You might like to read L. =head2 Copyright and License You should have received a I file, but the license is also noted in the module files. About the only thing you can't do is pretend that you wrote code that you didn't. =head2 Good luck! Enjoy, brian d foy, bdfoy@cpan.org =cut Test-Output-1.031/t/000755 000765 000024 00000000000 13067023754 014443 5ustar00brianstaff000000 000000 Test-Output-1.031/xt/000755 000765 000024 00000000000 13067023751 014630 5ustar00brianstaff000000 000000 Test-Output-1.031/xt/changes.t000644 000765 000024 00000000203 13067023736 016423 0ustar00brianstaff000000 000000 use Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); Test-Output-1.031/t/00.load.t000644 000765 000024 00000000170 13067023736 015763 0ustar00brianstaff000000 000000 use Test::More tests => 1; BEGIN { use_ok( 'Test::Output' ); } diag( "Testing Test::Output $Test::Output::VERSION" ); Test-Output-1.031/t/binmode.t000644 000765 000024 00000000321 13067023736 016241 0ustar00brianstaff000000 000000 #!perl use Test::Tester; use Test::More tests => 1; use Test::Output; use strict; use warnings; eval { stdout_is( sub { binmode STDOUT; print 'foo'; }, 'foo', "The binmode doesn't blow up" ); }; Test-Output-1.031/t/carp-5.6.t000644 000765 000024 00000000566 13067023736 016072 0ustar00brianstaff000000 000000 use Test::More tests => 3; my $class = 'Test::Output'; my $sub = 'stderr_from'; use_ok( $class ); can_ok( $class, $sub ); use Carp qw(carp); my $message = "This is from carp"; my $output = do { no strict 'refs'; &{ "${class}::$sub" }( sub { carp $message } ); }; like( $output, qr/^\Q$message\E at .* line \d+/, "stderr_from captures carp message" );Test-Output-1.031/t/combined_is.t000644 000765 000024 00000014063 13067023736 017107 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 98; use Test::Output; use strict; use warnings; check_test( sub { combined_is(sub { print "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { combined_is(sub { print STDERR "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { combined_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; print "TEST AGAIN\n"; }, "TEST OUT\nTEST ERR\nTEST AGAIN\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { combined_is(sub { printf("TEST OUT - %d\n",25); }, "TEST OUT - 25\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { combined_is(sub { print "TEST OUT"; }, "TEST OUT STDOUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { combined_is(sub { print STDERR "TEST OUT"}, "TEST OUT STDERR", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { combined_is(sub { print "TEST ERR\n"; print STDERR "TEST OUT\n"}, "TEST ERR STDOUT\nTEST OUT STDERR\n", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST ERR\nTEST OUT\n\nnot:\nTEST ERR STDOUT\nTEST OUT STDERR\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { combined_is { print "TEST OUT\n"; } "TEST OUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'codeblock STDOUT matches success' ); check_test( sub { combined_is { print STDERR "TEST OUT\n"; } "TEST OUT\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { combined_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; print "TEST OUT AGAIN\n"; } "TEST OUT\nTEST ERR\nTEST OUT AGAIN\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { combined_is { printf("TEST OUT - %d\n",25); } "TEST OUT - 25\n", 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { combined_is { print "TEST OUT"; } "TEST OUT STDOUT", 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { combined_is { print STDERR "TEST OUT"} "TEST OUT STDERR", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { combined_is { print "TEST ERR\n"; print STDERR "TEST OUT\n"} "TEST ERR STDOUT\nTEST OUT STDERR\n", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR are:\nTEST ERR\nTEST OUT\n\nnot:\nTEST ERR STDOUT\nTEST OUT STDERR\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); Test-Output-1.031/t/combined_isnt.t000644 000765 000024 00000014167 13067023736 017456 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 98; use Test::Output; use strict; use warnings; check_test( sub { combined_isnt(sub { print "TEST OUT\n"; }, "TEST STDOUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); check_test( sub { combined_isnt(sub { print STDERR "TEST OUT\n"; }, "TEST STDERR\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not matching success' ); check_test( sub { combined_isnt(sub { print "TEST STDOUT\n"; print STDERR "TEST STDERR\n"; print "TEST STDOUT AGAIN\n"; }, "TEST OUT\nTEST ERR\nTEST AGAIN\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR not matching success' ); check_test( sub { combined_isnt(sub { printf("TEST OUT - %d\n",25); }, "TEST OUT - 42\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not matching success' ); check_test( sub { combined_isnt(sub { print "TEST OUT"; }, "TEST OUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matching failure' ); check_test( sub { combined_isnt(sub { print STDERR "TEST OUT"}, "TEST OUT", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDERR matching failure' ); check_test( sub { combined_isnt(sub { print "TEST ERR\n"; print STDERR "TEST OUT\n"}, "TEST ERR\nTEST OUT\n", 'Testing STDOUT & STDERR failure' ) }, { ok => 0, name => 'Testing STDOUT & STDERR failure', diag => "STDOUT & STDERR:\nTEST ERR\nTEST OUT\n\nmatching:\nTEST ERR\nTEST OUT\n\nnot expected\n", },'STDOUT and STDERR matching failure' ); check_test( sub { combined_isnt { print "TEST OUT\n"; } "TEST STDOUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'codeblock STDOUT not matching success' ); check_test( sub { combined_isnt { print STDERR "TEST OUT\n"; } "TEST STDERR\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'codeblock STDERR not matching success' ); check_test( sub { combined_isnt { print "TEST STDOUT\n"; print STDERR "TEST STDERR\n"; print "TEST STDOUT AGAIN\n"; } "TEST OUT\nTEST ERR\nTEST OUT AGAIN\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'codeblock STDOUT & STDERR not matching success' ); check_test( sub { combined_isnt { printf("TEST OUT - %d\n",25); } "TEST OUT - 42\n", 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'codeblock STDOUT printf not matching success' ); check_test( sub { combined_isnt { print "TEST OUT"; } "TEST OUT", 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'codeblock STDOUT matching failure' ); check_test( sub { combined_isnt { print STDERR "TEST OUT"} "TEST OUT", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'codeblock STDERR not matching failure' ); check_test( sub { combined_isnt { print "TEST ERR\n"; print STDERR "TEST OUT\n"} "TEST ERR\nTEST OUT\n", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT & STDERR:\nTEST ERR\nTEST OUT\n\nmatching:\nTEST ERR\nTEST OUT\n\nnot expected\n", },'codeblock STDOUT and STDERR matching failure' ); Test-Output-1.031/t/combined_like.t000644 000765 000024 00000006704 13067023736 017423 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 49; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { combined_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/ERR/i; check_test( sub { combined_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_like(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'combined_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\ndon't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { combined_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_like { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'combined_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\ndon't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } Test-Output-1.031/t/combined_unlike.t000644 000765 000024 00000006752 13067023736 017771 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 49; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/err/; check_test( sub { combined_unlike(sub { print "TEST OUT\n"; print "TEST ERR\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_unlike(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'combined_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/; check_test( sub { combined_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\nmatching:\n$regex\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { combined_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'codeblock STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { combined_unlike { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'combined_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'codeblock bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/; check_test( sub { combined_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT & STDERR:\nTEST OUT\n\nmatching:\n$regex\nnot expected\n", },'codeblock STDOUT matching failure' ); } Test-Output-1.031/t/output_is.t000644 000765 000024 00000025164 13067023736 016673 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 168; use Test::Output; use strict; use warnings; check_test( sub { output_is(sub { print "TEST OUT\n"; }, "TEST OUT\n", '', 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { output_is(sub { print STDERR "TEST OUT\n"; }, '', "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { output_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, "TEST OUT\n", "TEST ERR\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { output_is(sub { printf("TEST OUT - %d\n",25); }, "TEST OUT - 25\n", '', 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { output_is(sub { print "TEST OUT"; }, "TEST OUT STDOUT", '', 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT is:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { output_is(sub { print STDERR "TEST OUT"}, '', "TEST OUT STDERR", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { output_is(sub { print "TEST ERR"; print STDERR "TEST OUT"}, 'TEST ERR STDOUT', "TEST OUT STDERR", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\nTEST ERR STDOUT\nas expected\nSTDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, undef, "TEST ERR\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT undef match success' ); check_test( sub { output_is(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, "TEST OUT\n", undef, 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT match success STDERR undef' ); check_test( sub { output_is(sub { }, undef, undef, 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR undef match success' ); check_test( sub { output_is(sub { print "TEST ERR"; print STDERR "TEST OUT"}, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\n\nas expected\nSTDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is(sub { print STDERR "TEST OUT"}, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT undef and STDERR not matching failure' ); check_test( sub { output_is { print "TEST OUT\n"; } "TEST OUT\n", '', 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { output_is { print STDERR "TEST OUT\n"; } '', "TEST OUT\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matches success' ); check_test( sub { output_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } "TEST OUT\n", "TEST ERR\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR match success' ); check_test( sub { output_is { printf("TEST OUT - %d\n",25); } "TEST OUT - 25\n", '', 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf match success' ); check_test( sub { output_is { print "TEST OUT"; } "TEST OUT STDOUT", '', 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT is:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); check_test( sub { output_is { print STDERR "TEST OUT"} '', "TEST OUT STDERR", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDERR not matching failure' ); check_test( sub { output_is { print "TEST ERR"; print STDERR "TEST OUT"} 'TEST ERR STDOUT', "TEST OUT STDERR", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\nTEST ERR STDOUT\nas expected\nSTDERR is:\nTEST OUT\nnot:\nTEST OUT STDERR\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } undef, "TEST ERR\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT undef match success' ); check_test( sub { output_is { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } "TEST OUT\n", undef, 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT match success STDERR undef' ); check_test( sub { output_is { } undef, undef, 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR undef match success' ); check_test( sub { output_is { print "TEST ERR"; print STDERR "TEST OUT"} undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT is:\nTEST ERR\nnot:\n\nas expected\nSTDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT and STDERR not matching failure' ); check_test( sub { output_is { print STDERR "TEST OUT"} undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR is:\nTEST OUT\nnot:\n\nas expected\n", },'STDOUT undef and STDERR not matching failure' ); Test-Output-1.031/t/output_isnt.t000644 000765 000024 00000025713 13067023736 017235 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 168; use Test::Output; use strict; use warnings; check_test( sub { output_isnt(sub { print "TEST OUT\n"; print STDERR "TEST OUT"}, "TEST OUT STDOUT\n", undef, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { output_isnt(sub { print "TEST OUT\n"; print STDERR "TEST OUT\n"; }, undef, "TEST OUT STDERR\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { output_isnt(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, "TEST OUT STDOUT\n", "TEST ERR STDERR\n", 'Testing STDOUT & STDERR' ) },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR not equal success' ); check_test( sub { output_isnt(sub { printf("TEST OUT - %d\n",25); print STDERR "TEST OUT"}, "TEST OUT - 42\n", undef, 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { output_isnt(sub { printf STDERR ("TEST OUT - %d\n",25); }, undef, "TEST OUT - 42\n", 'Testing STDERR printf' ) },{ ok => 1, name => 'Testing STDERR printf', diag => '', },'STDERR printf not equal success' ); check_test( sub { output_isnt(sub { print "TEST OUT - 25"; printf STDERR "TEST OUT - 25"; }, "TEST OUT - 25", "TEST OUT - 25", 'Testing STDOUT & STDERR print' ) },{ ok => 0, name => 'Testing STDOUT & STDERR print', diag => "STDOUT:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\nSTDERR:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\n", },'STDOUT & STDERR matches failure' ); check_test( sub { output_isnt(sub { print "TEST OUT"; print STDERR "TEST OUT"}, "TEST OUT", '', 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt(sub { print "TEST OUT"; print STDERR "TEST OUT"}, '', "TEST OUT", 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt(sub { print "TEST OUT"; print STDERR "TEST OUT"}, undef, undef, 'Testing STDERR failure' ) }, { ok => 1, name => 'Testing STDERR failure', diag => '', },'STDOUT & STDERR not matching success' ); check_test( sub { output_isnt(sub { print "TEST OUT"; }, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\n\nmatching:\n\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt(sub { print STDERR "TEST OUT"; }, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt(sub { }, undef, undef, 'Testing STDERR failure' ) }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\nSTDERR:\n\nmatching:\n\nnot expected\n", },'STDOUT & STDERR matches failure' ); check_test( sub { output_isnt { print "TEST OUT\n"; print STDERR "TEST OUT"} "TEST OUT STDOUT\n", undef, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { output_isnt { print "TEST OUT\n"; print STDERR "TEST OUT\n"; } undef, "TEST OUT STDERR\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { output_isnt { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } "TEST OUT STDOUT\n", "TEST ERR STDERR\n", 'Testing STDOUT & STDERR' },{ ok => 1, name => 'Testing STDOUT & STDERR', diag => '', },'STDOUT & STDERR not equal success' ); check_test( sub { output_isnt { printf("TEST OUT - %d\n",25); print STDERR "TEST OUT"} "TEST OUT - 42\n", undef, 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { output_isnt { printf STDERR ("TEST OUT - %d\n",25); } undef, "TEST OUT - 42\n", 'Testing STDERR printf' },{ ok => 1, name => 'Testing STDERR printf', diag => '', },'STDERR printf not equal success' ); check_test( sub { output_isnt { print "TEST OUT - 25"; printf STDERR "TEST OUT - 25"; } "TEST OUT - 25", "TEST OUT - 25", 'Testing STDOUT & STDERR print' },{ ok => 0, name => 'Testing STDOUT & STDERR print', diag => "STDOUT:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\nSTDERR:\nTEST OUT - 25\nmatching:\nTEST OUT - 25\nnot expected\n", },'STDOUT & STDERR matches failure' ); check_test( sub { output_isnt { print "TEST OUT"; print STDERR "TEST OUT"} "TEST OUT", '', 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt { print "TEST OUT"; print STDERR "TEST OUT"} '', "TEST OUT", 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt { print "TEST OUT"; print STDERR "TEST OUT"} undef, undef, 'Testing STDERR failure' }, { ok => 1, name => 'Testing STDERR failure', diag => '', },'STDOUT & STDERR not matching success' ); check_test( sub { output_isnt { print "TEST OUT"; } undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDERR:\n\nmatching:\n\nnot expected\n", },'STDERR matches failure' ); check_test( sub { output_isnt { print STDERR "TEST OUT"; } undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { output_isnt { } undef, undef, 'Testing STDERR failure' }, { ok => 0, name => 'Testing STDERR failure', diag => "STDOUT:\n\nmatching:\n\nnot expected\nSTDERR:\n\nmatching:\n\nnot expected\n", },'STDOUT & STDERR matches failure' ); Test-Output-1.031/t/output_like.t000644 000765 000024 00000033473 13067023736 017206 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 154; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = qr/ERR/i; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT matching STDERR ignored success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/; my $regex_err = qr/ERR/; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT is:\nTEST OUT\n\nnot:\n\nas expected\nSTDERR is:\nTEST ERR\n\nnot:\n\nas expected\n", },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/ERR/i; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_like_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_like_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/err/; check_test( sub { output_like(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\nSTDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDOUT & STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like(sub { }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT & STDERR undef matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like(sub { print STDERR "TEST OUT\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR is:\nTEST OUT\n\nnot:\n\nas expected\n", },'STDOUT & STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT matching STDERR ignored success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT is:\nTEST OUT\n\nnot:\n\nas expected\nSTDERR is:\nTEST ERR\n\nnot:\n\nas expected\n", },'STDOUT ignored and STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_like_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_like_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/err/; check_test( sub { output_like { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex_out\nas expected\nSTDERR:\nTEST ERR\n\ndoesn't match:\n$regex_err\nas expected\n", },'STDOUT & STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like { } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT & STDERR undef matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err; check_test( sub { output_like { print STDERR "TEST OUT\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR is:\nTEST OUT\n\nnot:\n\nas expected\n", },'STDOUT & STDERR not matching failure' ); } Test-Output-1.031/t/output_unlike.t000644 000765 000024 00000024425 13067023736 017546 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 112; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/i; my $regex_err = qr/OUT/i; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err = qr/OUT/i; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/i; my $regex_err; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/err/; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_unlike_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, depth => 2, name => 'output_unlike_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/; my $regex_err = qr/ERR/; check_test( sub { output_unlike(sub { print "TEST OUT\n"; print STDERR "TEST ERR\n"; }, $regex_out, $regex_err, 'Testing STDOUT and STDERR match' ) },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\nSTDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/; my $regex_err = qr/OUT/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out; my $regex_err = qr/OUT/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/ERR/i; my $regex_err; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 1, name => 'Testing STDOUT and STDERR match', diag => '', },'STDOUT and STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = 'OUT'; my $regex_err = qr/err/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_unlike_STDOUT', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDOUT bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/i; my $regex_err = 'OUT'; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, depth => 2, name => 'output_unlike_STDERR', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/; my $regex_err = qr/ERR/i; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/out/i; my $regex_err = qr/err/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex_out = qr/OUT/; my $regex_err = qr/ERR/; check_test( sub { output_unlike { print "TEST OUT\n"; print STDERR "TEST ERR\n"; } $regex_out, $regex_err, 'Testing STDOUT and STDERR match' },{ ok => 0, name => 'Testing STDOUT and STDERR match', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex_out\nnot expected\nSTDERR:\nTEST ERR\n\nmatches:\n$regex_err\nnot expected\n", },'STDERR matching failure' ); } Test-Output-1.031/t/pod-coverage.t000644 000765 000024 00000000254 13067023736 017204 0ustar00brianstaff000000 000000 #!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Test-Output-1.031/t/pod.t000644 000765 000024 00000000214 13067023736 015407 0ustar00brianstaff000000 000000 #!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Test-Output-1.031/t/stderr_is.t000644 000765 000024 00000004713 13067023736 016633 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; check_test( sub { stderr_is(sub { print STDERR "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is(sub { print STDERR "TEST", " ", "OUT", "\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is(sub { local $, = " "; print STDERR "TEST", "OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is(sub { print STDERR "TEST OUT\n"; }, "TEST OUT STDERR\n", 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR is:\nTEST OUT\n\nnot:\nTEST OUT STDERR\n\nas expected\n", },'STDERR not matching failure' ); check_test( sub { stderr_is { print STDERR "TEST OUT\n"; } "TEST OUT\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); check_test( sub { stderr_is { print STDERR "TEST OUT\n"; } "TEST OUT STDERR\n", 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR is:\nTEST OUT\n\nnot:\nTEST OUT STDERR\n\nas expected\n", },'STDERR not matching failure' ); Test-Output-1.031/t/stderr_isnt.t000644 000765 000024 00000003225 13067023736 017172 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 28; use Test::Output; use strict; use warnings; check_test( sub { stderr_isnt(sub { print STDERR "TEST OUT\n"; }, "TEST OUT STDERR\n", 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { stderr_isnt(sub { print STDERR "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\nTEST OUT\n\nnot expected\n", },'STDERR matches failure' ); check_test( sub { stderr_isnt { print STDERR "TEST OUT\n"; } "TEST OUT STDERR\n", 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR not equal success' ); check_test( sub { stderr_isnt { print STDERR "TEST OUT\n"; } "TEST OUT\n", 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\nTEST OUT\n\nnot expected\n", },'STDERR matches failure' ); Test-Output-1.031/t/stderr_like.t000644 000765 000024 00000006044 13067023736 017143 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stderr_like(sub { print STDERR "TEST OUT\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = 'OUT'; check_test( sub { stderr_like(sub { print STDERR "TEST OUT\n"; }, 'OUT', 'Testing STDERR' ) },{ ok => 0, depth => 2, name => 'stderr_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stderr_like(sub { print STDERR "TEST OUT\n"; }, qr/out/, 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDERR not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stderr_like { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = 'OUT'; check_test( sub { stderr_like { print STDERR "TEST OUT\n"; } 'OUT', 'Testing STDERR' },{ ok => 0, depth => 2, name => 'stderr_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR bad regex success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stderr_like { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDERR not matching failure' ); } Test-Output-1.031/t/stderr_unlike.t000644 000765 000024 00000005754 13067023736 017515 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stderr_unlike(sub { print STDERR "TEST OUT\n"; }, $regex, 'Testing STDERR' ) },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stderr_unlike(sub { print STDERR "TEST OUT\n"; }, 'OUT', 'Testing STDERR' ) },{ ok => 0, depth => 2, name => 'stderr_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR matching success' ); { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # my $regex = qr/OUT/; check_test( sub { stderr_unlike(sub { print STDERR "TEST OUT\n"; }, $regex, 'Testing STDERR' ) },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDERR not matching failure' ); } { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # my $regex = qr/out/; check_test( sub { stderr_unlike { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 1, name => 'Testing STDERR', diag => '', },'STDERR matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stderr_unlike { print STDERR "TEST OUT\n"; } 'OUT', 'Testing STDERR' },{ ok => 0, depth => 2, name => 'stderr_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'STDERR matching success' ); { # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # my $regex = qr/OUT/; check_test( sub { stderr_unlike { print STDERR "TEST OUT\n"; } $regex, 'Testing STDERR' },{ ok => 0, name => 'Testing STDERR', diag => "STDERR:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDERR not matching failure' ); } Test-Output-1.031/t/stdout_is.t000644 000765 000024 00000005103 13067023736 016644 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 35; use Test::Output; use strict; use warnings; check_test( sub { stdout_is(sub { print "TEST OUT\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { stdout_is(sub { print "TEST", " ", "OUT", "\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { stdout_is(sub { local $, = " "; print "TEST", "OUT\n"; }, "TEST OUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); check_test( sub { stdout_is(sub { printf("TEST OUT - %d\n",42); }, "TEST OUT - 42\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf matches success' ); check_test( sub { stdout_is(sub { print "TEST OUT"; }, "TEST OUT STDOUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT is:\nTEST OUT\nnot:\nTEST OUT STDOUT\nas expected\n", },'STDOUT not matching failure' ); __END__ # This doesn't work yet SKIP: { skip 'Perl 5.10 required for this test', 7 unless $] >= 5.010; BEGIN { eval "use feature qw(say)" if $] >= 5.010 }; check_test( sub { stdout_is { eval 'say( "TEST OUT" );'; } "TEST OUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matches success' ); }; Test-Output-1.031/t/stdout_isnt.t000644 000765 000024 00000004646 13067023736 017221 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; check_test( sub { stdout_isnt(sub { print "TEST OUT\n"; }, "TEST OUT STDOUT\n", 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { stdout_isnt(sub { printf("TEST OUT - %d\n",42); }, "TEST OUT - 25\n", 'Testing STDOUT printf' ) },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { stdout_isnt(sub { print "TEST OUT"; }, "TEST OUT", 'Testing STDOUT failure' ) }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); check_test( sub { stdout_isnt { print "TEST OUT\n"; } "TEST OUT STDOUT\n", 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not equal success' ); check_test( sub { stdout_isnt { printf("TEST OUT - %d\n",42); } "TEST OUT - 25\n", 'Testing STDOUT printf' },{ ok => 1, name => 'Testing STDOUT printf', diag => '', },'STDOUT printf not equal success' ); check_test( sub { stdout_isnt { print "TEST OUT"; } "TEST OUT", 'Testing STDOUT failure' }, { ok => 0, name => 'Testing STDOUT failure', diag => "STDOUT:\nTEST OUT\nmatching:\nTEST OUT\nnot expected\n", },'STDOUT matches failure' ); Test-Output-1.031/t/stdout_like.t000644 000765 000024 00000005641 13067023736 017164 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stdout_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_like(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'stdout_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_like(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/i; check_test( sub { stdout_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_like { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'stdout_like', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_like { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\ndoesn't match:\n$regex\nas expected\n", },'STDOUT not matching failure' ); } Test-Output-1.031/t/stdout_unlike.t000644 000765 000024 00000005655 13067023736 017534 0ustar00brianstaff000000 000000 use Test::Tester; use Test::More tests => 42; use Test::Output; use strict; use warnings; # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_unlike(sub { print "TEST OUT\n"; }, 'OUT', 'Testing STDOUT' ) },{ ok => 0, depth => 2, name => 'stdout_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/(?-xism:OUT)/; check_test( sub { stdout_unlike(sub { print "TEST OUT\n"; }, $regex, 'Testing STDOUT' ) },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDOUT matching failure' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/out/; check_test( sub { stdout_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 1, name => 'Testing STDOUT', diag => '', },'STDOUT not matching success' ); } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # check_test( sub { stdout_unlike { print "TEST OUT\n"; } 'OUT', 'Testing STDOUT' },{ ok => 0, depth => 2, name => 'stdout_unlike', diag => "'OUT' doesn't look much like a regex to me.\n", },'bad regex' ); # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # { my $regex = qr/OUT/; check_test( sub { stdout_unlike { print "TEST OUT\n"; } $regex, 'Testing STDOUT' },{ ok => 0, name => 'Testing STDOUT', diag => "STDOUT:\nTEST OUT\n\nmatches:\n$regex\nnot expected\n", },'STDOUT matching failure' ); } Test-Output-1.031/lib/Test/000755 000765 000024 00000000000 13067023751 015662 5ustar00brianstaff000000 000000 Test-Output-1.031/lib/Test/Output.pm000644 000765 000024 00000053626 13067023736 017537 0ustar00brianstaff000000 000000 package Test::Output; use warnings; use strict; use Test::Builder; use Capture::Tiny qw/capture capture_stdout capture_stderr capture_merged/; use Exporter qw(import); our %EXPORT_TAGS = ( stdout => [ qw( stdout_is stdout_isnt stdout_like stdout_unlike ) ], stderr => [ qw( stderr_is stderr_isnt stderr_like stderr_unlike ) ], output => [ qw( output_is output_isnt output_like output_unlike ) ], combined => [ qw( combined_is combined_isnt combined_like combined_unlike ) ], functions => [ qw( output_from stderr_from stdout_from combined_from ) ], tests => [ qw( output_is output_isnt output_like output_unlike stderr_is stderr_isnt stderr_like stderr_unlike stdout_is stdout_isnt stdout_like stdout_unlike combined_is combined_isnt combined_like combined_unlike ) ], all => [ qw( output_is output_isnt output_like output_unlike stderr_is stderr_isnt stderr_like stderr_unlike stdout_is stdout_isnt stdout_like stdout_unlike combined_is combined_isnt combined_like combined_unlike output_from stderr_from stdout_from combined_from ) ], ); our @EXPORT = keys %{ { map { $_ => 1 } map { @{ $EXPORT_TAGS{$_} } } keys %EXPORT_TAGS } }; my $Test = Test::Builder->new; =encoding utf8 =head1 NAME Test::Output - Utilities to test STDOUT and STDERR messages. =cut our $VERSION = '1.031'; =head1 SYNOPSIS use Test::More tests => 4; use Test::Output; sub writer { print "Write out.\n"; print STDERR "Error out.\n"; } stdout_is(\&writer,"Write out.\n",'Test STDOUT'); stderr_isnt(\&writer,"No error out.\n",'Test STDERR'); combined_is( \&writer, "Write out.\nError out.\n", 'Test STDOUT & STDERR combined' ); output_is( \&writer, "Write out.\n", "Error out.\n", 'Test STDOUT & STDERR' ); # Use bare blocks. stdout_is { print "test" } "test", "Test STDOUT"; stderr_isnt { print "bad test" } "test", "Test STDERR"; output_is { print 'STDOUT'; print STDERR 'STDERR' } "STDOUT", "STDERR", "Test output"; =head1 DESCRIPTION Test::Output provides a simple interface for testing output sent to C or C. A number of different utilities are included to try and be as flexible as possible to the tester. Likewise, L provides a much more robust capture mechanism without than the original L. =cut =head1 TESTS =cut =head2 STDOUT =over 4 =item B =item B stdout_is ( $coderef, $expected, 'description' ); stdout_is { ... } $expected, 'description'; stdout_isnt( $coderef, $expected, 'description' ); stdout_isnt { ... } $expected, 'description'; C captures output sent to C from C<$coderef> and compares it against C<$expected>. The test passes if equal. C passes if C is not equal to C<$expected>. =cut sub stdout_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stdout = stdout_from($test); my $ok = ( $stdout eq $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT is:\n$stdout\nnot:\n$expected\nas expected"); return $ok; } sub stdout_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stdout = stdout_from($test); my $ok = ( $stdout ne $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\nmatching:\n$expected\nnot expected"); return $ok; } =item B =item B stdout_like ( $coderef, qr/$expected/, 'description' ); stdout_like { ... } qr/$expected/, 'description'; stdout_unlike( $coderef, qr/$expected/, 'description' ); stdout_unlike { ... } qr/$expected/, 'description'; C captures the output sent to C from C<$coderef> and compares it to the regex in C<$expected>. The test passes if the regex matches. C passes if STDOUT does not match the regex. =back =cut sub stdout_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stdout_like' => $expected ) ) { return $regextest; } my $stdout = stdout_from($test); my $ok = ( $stdout =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\ndoesn't match:\n$expected\nas expected"); return $ok; } sub stdout_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stdout_unlike' => $expected ) ) { return $regextest; } my $stdout = stdout_from($test); my $ok = ( $stdout !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDOUT:\n$stdout\nmatches:\n$expected\nnot expected"); return $ok; } =head2 STDERR =over 4 =item B =item B stderr_is ( $coderef, $expected, 'description' ); stderr_is {... } $expected, 'description'; stderr_isnt( $coderef, $expected, 'description' ); stderr_isnt {... } $expected, 'description'; C is similar to C, except that it captures C. The test passes if C from C<$coderef> equals C<$expected>. C passes if C is not equal to C<$expected>. =cut sub stderr_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stderr = stderr_from($test); my $ok = ( $stderr eq $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR is:\n$stderr\nnot:\n$expected\nas expected"); return $ok; } sub stderr_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $stderr = stderr_from($test); my $ok = ( $stderr ne $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); return $ok; } =item B =item B stderr_like ( $coderef, qr/$expected/, 'description' ); stderr_like { ...} qr/$expected/, 'description'; stderr_unlike( $coderef, qr/$expected/, 'description' ); stderr_unlike { ...} qr/$expected/, 'description'; C is similar to C except that it compares the regex C<$expected> to C captured from C<$codref>. The test passes if the regex matches. C passes if C does not match the regex. =back =cut sub stderr_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stderr_like' => $expected ) ) { return $regextest; } my $stderr = stderr_from($test); my $ok = ( $stderr =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\ndoesn't match:\n$expected\nas expected"); return $ok; } sub stderr_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'stderr_unlike' => $expected ) ) { return $regextest; } my $stderr = stderr_from($test); my $ok = ( $stderr !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag("STDERR:\n$stderr\nmatches:\n$expected\nnot expected"); return $ok; } =head2 COMBINED OUTPUT =over 4 =item B =item B combined_is ( $coderef, $expected, 'description' ); combined_is {... } $expected, 'description'; combined_isnt ( $coderef, $expected, 'description' ); combined_isnt {... } $expected, 'description'; C directs C to C then captures C. This is equivalent to UNIXs C<< 2>&1 >>. The test passes if the combined C and C from $coderef equals $expected. C passes if combined C and C are not equal to C<$expected>. =cut sub combined_is (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $combined = combined_from($test); my $ok = ( $combined eq $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR are:\n$combined\nnot:\n$expected\nas expected"); return $ok; } sub combined_isnt (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my $combined = combined_from($test); my $ok = ( $combined ne $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); return $ok; } =item B =item B combined_like ( $coderef, qr/$expected/, 'description' ); combined_like { ...} qr/$expected/, 'description'; combined_unlike ( $coderef, qr/$expected/, 'description' ); combined_unlike { ...} qr/$expected/, 'description'; C is similar to C except that it compares a regex (C<$expected)> to C and C captured from C<$codref>. The test passes if the regex matches. C passes if the combined C and C does not match the regex. =back =cut sub combined_like (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'combined_like' => $expected ) ) { return $regextest; } my $combined = combined_from($test); my $ok = ( $combined =~ $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\ndon't match:\n$expected\nas expected"); return $ok; } sub combined_unlike (&$;$$) { my $test = shift; my $expected = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; unless ( my $regextest = _chkregex( 'combined_unlike' => $expected ) ) { return $regextest; } my $combined = combined_from($test); my $ok = ( $combined !~ $expected ); $Test->ok( $ok, $description ) || $Test->diag( "STDOUT & STDERR:\n$combined\nmatching:\n$expected\nnot expected"); return $ok; } =head2 OUTPUT =over 4 =item B =item B output_is ( $coderef, $expected_stdout, $expected_stderr, 'description' ); output_is {... } $expected_stdout, $expected_stderr, 'description'; output_isnt( $coderef, $expected_stdout, $expected_stderr, 'description' ); output_isnt {... } $expected_stdout, $expected_stderr, 'description'; The C function is a combination of the C and C functions. For example: output_is(sub {print "foo"; print STDERR "bar";},'foo','bar'); is functionally equivalent to stdout_is(sub {print "foo";},'foo') && stderr_is(sub {print STDERR "bar";'bar'); except that C<$coderef> is only executed once. Unlike C and C which ignore STDERR and STDOUT respectively, C requires both C and C to match in order to pass. Setting either C<$expected_stdout> or C<$expected_stderr> to C ignores C or C respectively. output_is(sub {print "foo"; print STDERR "bar";},'foo',undef); is the same as stdout_is(sub {print "foo";},'foo') C provides the opposite function of C. It is a combination of C and C. output_isnt(sub {print "foo"; print STDERR "bar";},'bar','foo'); is functionally equivalent to stdout_is(sub {print "foo";},'bar') && stderr_is(sub {print STDERR "bar";'foo'); As with C, setting either C<$expected_stdout> or C<$expected_stderr> to C ignores the output to that facility. output_isnt(sub {print "foo"; print STDERR "bar";},undef,'foo'); is the same as stderr_is(sub {print STDERR "bar";},'foo') =cut sub output_is (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; my $diag; if ( defined($experr) && defined($expout) ) { unless ( $stdout eq $expout ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; } unless ( $stderr eq $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout eq $expout ); $diag .= "STDOUT is:\n$stdout\nnot:\n$expout\nas expected"; } elsif ( defined($experr) ) { $ok = ( $stderr eq $experr ); $diag .= "STDERR is:\n$stderr\nnot:\n$experr\nas expected"; } else { unless ( $stdout eq '' ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; } unless ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } sub output_isnt (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; my $diag; if ( defined($experr) && defined($expout) ) { if ( $stdout eq $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; } if ( $stderr eq $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout ne $expout ); $diag = "STDOUT:\n$stdout\nmatching:\n$expout\nnot expected"; } elsif ( defined($experr) ) { $ok = ( $stderr ne $experr ); $diag = "STDERR:\n$stderr\nmatching:\n$experr\nnot expected"; } else { if ( $stdout eq '' ) { $ok = 0; $diag = "STDOUT:\n$stdout\nmatching:\n\nnot expected"; } if ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatching:\n\nnot expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } =item B =item B output_like ( $coderef, $regex_stdout, $regex_stderr, 'description' ); output_like { ... } $regex_stdout, $regex_stderr, 'description'; output_unlike( $coderef, $regex_stdout, $regex_stderr, 'description' ); output_unlike { ... } $regex_stdout, $regex_stderr, 'description'; C and C follow the same principles as C and C except they use a regular expression for matching. C attempts to match C<$regex_stdout> and C<$regex_stderr> against C and C produced by $coderef. The test passes if both match. output_like(sub {print "foo"; print STDERR "bar";},qr/foo/,qr/bar/); The above test is successful. Like C, setting either C<$regex_stdout> or C<$regex_stderr> to C ignores the output to that facility. output_like(sub {print "foo"; print STDERR "bar";},qr/foo/,undef); is the same as stdout_like(sub {print "foo"; print STDERR "bar";},qr/foo/); C test pass if output from C<$coderef> doesn't match C<$regex_stdout> and C<$regex_stderr>. =back =cut sub output_like (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; unless ( my $regextest = _chkregex( 'output_like_STDERR' => $experr, 'output_like_STDOUT' => $expout ) ) { return $regextest; } my $diag; if ( defined($experr) && defined($expout) ) { unless ( $stdout =~ $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; } unless ( $stderr =~ $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout =~ $expout ); $diag .= "STDOUT:\n$stdout\ndoesn't match:\n$expout\nas expected"; } elsif ( defined($experr) ) { $ok = ( $stderr =~ $experr ); $diag .= "STDERR:\n$stderr\ndoesn't match:\n$experr\nas expected"; } else { unless ( $stdout eq '' ) { $ok = 0; $diag .= "STDOUT is:\n$stdout\nnot:\n\nas expected"; } unless ( $stderr eq '' ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR is:\n$stderr\nnot:\n\nas expected"; } } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } sub output_unlike (&$$;$$) { my $test = shift; my $expout = shift; my $experr = shift; my $options = shift if ( ref( $_[0] ) ); my $description = shift; my ( $stdout, $stderr ) = output_from($test); my $ok = 1; unless ( my $regextest = _chkregex( 'output_unlike_STDERR' => $experr, 'output_unlike_STDOUT' => $expout ) ) { return $regextest; } my $diag; if ( defined($experr) && defined($expout) ) { if ( $stdout =~ $expout ) { $ok = 0; $diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; } if ( $stderr =~ $experr ) { $diag .= "\n" unless ($ok); $ok = 0; $diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; } } elsif ( defined($expout) ) { $ok = ( $stdout !~ $expout ); $diag .= "STDOUT:\n$stdout\nmatches:\n$expout\nnot expected"; } elsif ( defined($experr) ) { $ok = ( $stderr !~ $experr ); $diag .= "STDERR:\n$stderr\nmatches:\n$experr\nnot expected"; } $Test->ok( $ok, $description ) || $Test->diag($diag); return $ok; } =head1 EXPORTS By default, all subroutines are exported by default. =over 4 =item * :stdout - the subs with C in the name. =item * :stderr - the subs with C in the name. =item * :functions - the subs with C<_from> at the end. =item * :output - the subs with C in the name. =item * :combined - the subs with C in the name. =item * :tests - everything that outputs TAP =item * :all - everything (which is the same as the default) =back =head1 FUNCTIONS =cut =head2 stdout_from my $stdout = stdout_from($coderef) my $stdout = stdout_from { ... }; stdout_from() executes $coderef and captures STDOUT. =cut sub stdout_from (&) { my $test = shift; my $stdout = capture_stdout { select( ( select(STDOUT), $| = 1 )[0] ); $test->() }; return $stdout; } =head2 stderr_from my $stderr = stderr_from($coderef) my $stderr = stderr_from { ... }; C executes C<$coderef> and captures C. =cut sub stderr_from (&) { my $test = shift; # XXX why is this here and not in output_from or combined_from -- xdg, 2012-05-13 local $SIG{__WARN__} = sub { print STDERR @_ } if $] < 5.008; my $stderr = capture_stderr { select( ( select(STDERR), $| = 1 )[0] ); $test->() }; return $stderr; } =head2 output_from my ($stdout, $stderr) = output_from($coderef) my ($stdout, $stderr) = output_from {...}; C executes C<$coderef> one time capturing both C and C. =cut sub output_from (&) { my $test = shift; my ($stdout, $stderr) = capture { select( ( select(STDOUT), $| = 1 )[0] ); select( ( select(STDERR), $| = 1 )[0] ); $test->(); }; return ( $stdout, $stderr ); } =head2 combined_from my $combined = combined_from($coderef); my $combined = combined_from {...}; C executes C<$coderef> one time combines C and C, and captures them. C is equivalent to using C<< 2>&1 >> in UNIX. =cut sub combined_from (&) { my $test = shift; my $combined = capture_merged { select( ( select(STDOUT), $| = 1 )[0] ); select( ( select(STDERR), $| = 1 )[0] ); $test->(); }; return $combined; } sub _chkregex { my %regexs = @_; foreach my $test ( keys(%regexs) ) { next unless ( defined( $regexs{$test} ) ); my $usable_regex = $Test->maybe_regex( $regexs{$test} ); unless ( defined($usable_regex) ) { my $ok = $Test->ok( 0, $test ); $Test->diag("'$regexs{$test}' doesn't look much like a regex to me."); # unless $ok; return $ok; } } return 1; } =head1 AUTHOR Currently maintained by brian d foy, C. Shawn Sorichetti, C<< >> =head1 SOURCE AVAILABILITY This module is in Github: http://github.com/briandfoy/test-output/tree/master =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 ACKNOWLEDGEMENTS Thanks to chromatic whose TieOut.pm was the basis for capturing output. Also thanks to rjbs for his help cleaning the documentation, and pushing me to L. (This feature has been removed since it uses none of L's strengths). Thanks to David Wheeler for providing code block support and tests. Thanks to Michael G Schwern for the solution to combining C and C. =head1 COPYRIGHT & LICENSE Copyright 2005-2013 Shawn Sorichetti, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Test::Output