]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blob - t/05-pass.t
Test pass() and fail()
[perl/modules/Test-Leaner.git] / t / 05-pass.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 plan skip_all => 'perl 5.8 required to test pass()' unless $] >= 5.008;
9
10 my $buf = '';
11 open my $memory_stream, '>', \$buf
12                       or plan skip_all => 'could not create the in-memory file';
13
14 plan tests => 5;
15
16 require Test::Leaner;
17
18 {
19  local $@;
20  eval { Test::Leaner::tap_stream($memory_stream) };
21  is $@, '', 'tap_stream($fh) does not croak';
22 }
23
24 {
25  local $@;
26  $buf = '';
27  seek $memory_stream, 0, 0;
28  eval { Test::Leaner::pass() };
29  is $@,   '',       'pass() does not croak';
30  is $buf, "ok 1\n", 'pass() produces the correct TAP code';
31 }
32
33 {
34  local $@;
35  $buf = '';
36  seek $memory_stream, 0, 0;
37  eval { Test::Leaner::pass('this is a comment') };
38  is $@,   '', 'pass("comment") does not croak';
39  is $buf, "ok 2 - this is a comment\n",
40               'pass("comment") produces the correct TAP code';
41 }