]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blob - t/06-fail.t
Factor the capturing logic into Test::Leaner::TestHelper
[perl/modules/Test-Leaner.git] / t / 06-fail.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use Test::Leaner ();
9
10 use lib 't/lib';
11 use Test::Leaner::TestHelper;
12
13 my $buf = '';
14 capture_to_buffer $buf or plan skip_all => 'perl 5.8 required to test fail()';
15
16
17 plan tests => 4;
18
19 reset_buffer {
20  local $@;
21  eval { Test::Leaner::fail() };
22  is $@,   '',           'fail() does not croak';
23  is $buf, "not ok 1\n", 'fail() produces the correct TAP code';
24 };
25
26 reset_buffer {
27  local $@;
28  eval { Test::Leaner::fail('this is a comment') };
29  is $@,   '', 'fail("comment") does not croak';
30  is $buf, "not ok 2 - this is a comment\n",
31               'fail("comment") produces the correct TAP code';
32 };