Show
Ignore:
Timestamp:
03/31/08 16:59:13 (7 years ago)
Author:
nekokak
Message:

lang/perl/Test-Declare: add prints_ok and stderr_ok.

Location:
lang/perl/Test-Declare
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Test-Declare/MANIFEST

    r8470 r8559  
    2626t/02_test_more.t 
    2727t/03_test_exception.t 
     28t/04_prints_ok.t 
     29t/05_stderr_ok.t 
    2830t/98_perlcritic.t 
    2931t/pod.t 
  • lang/perl/Test-Declare/lib/Test/Declare.pm

    r8547 r8559  
    3434    cmp_deeply re 
    3535    blocks 
     36    prints_ok stderr_ok 
    3637/); 
    3738 
     
    107108} 
    108109 
     110use IO::Scalar; 
     111sub prints_ok (&$;$) { ## no critic 
     112    my ($code, $expected, $name) = @_; 
     113 
     114    tie *STDOUT, 'IO::Scalar', \my $stdout; 
     115        $code->(); 
     116        like($stdout, qr/$expected/, $name||$test_block_name); 
     117    untie *STDOUT; 
     118} 
     119sub stderr_ok (&$;$) { ## no critic 
     120    my ($code, $expected, $name) = @_; 
     121 
     122    tie *STDERR, 'IO::Scalar', \my $stderr; 
     123        $code->(); 
     124        like($stderr, qr/$expected/, $name||$test_block_name); 
     125    untie *STDERR; 
     126} 
     127 
    1091281; 
    110129