]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blobdiff - t/05-pass.t
Factor the capturing logic into Test::Leaner::TestHelper
[perl/modules/Test-Leaner.git] / t / 05-pass.t
index f9997476d7a61a8e70cff64486569293c83d9d52..ecc6df18586eacbc49d034bb41a3c727662b80e4 100644 (file)
@@ -5,37 +5,27 @@ use warnings;
 
 use Test::More;
 
-plan skip_all => 'perl 5.8 required to test pass()' unless $] >= 5.008;
+use Test::Leaner ();
 
-my $buf = '';
-open my $memory_stream, '>', \$buf
-                      or plan skip_all => 'could not create the in-memory file';
-
-plan tests => 5;
+use lib 't/lib';
+use Test::Leaner::TestHelper;
 
-require Test::Leaner;
+my $buf = '';
+capture_to_buffer $buf or plan skip_all => 'perl 5.8 required to test pass()';
 
-{
- local $@;
- eval { Test::Leaner::tap_stream($memory_stream) };
- is $@, '', 'tap_stream($fh) does not croak';
-}
+plan tests => 4;
 
-{
+reset_buffer {
  local $@;
- $buf = '';
- seek $memory_stream, 0, 0;
  eval { Test::Leaner::pass() };
  is $@,   '',       'pass() does not croak';
  is $buf, "ok 1\n", 'pass() produces the correct TAP code';
-}
+};
 
-{
+reset_buffer {
  local $@;
- $buf = '';
- seek $memory_stream, 0, 0;
  eval { Test::Leaner::pass('this is a comment') };
  is $@,   '', 'pass("comment") does not croak';
  is $buf, "ok 2 - this is a comment\n",
               'pass("comment") produces the correct TAP code';
-}
+};