X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F06-fail.t;fp=t%2F06-fail.t;h=a3ed9e0c6c8ef3a8ffdc89ce79cbc031d513d30a;hb=c80a21dbcb4445fe4aebe276d439d2a2d8b310b1;hp=0000000000000000000000000000000000000000;hpb=da6dd0b8533e32433851119428d3bc4e1959599c;p=perl%2Fmodules%2FTest-Leaner.git diff --git a/t/06-fail.t b/t/06-fail.t new file mode 100644 index 0000000..a3ed9e0 --- /dev/null +++ b/t/06-fail.t @@ -0,0 +1,41 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More; + +plan skip_all => 'perl 5.8 required to test fail()' unless $] >= 5.008; + +my $buf = ''; +open my $memory_stream, '>', \$buf + or plan skip_all => 'could not create the in-memory file'; + +plan tests => 5; + +require Test::Leaner; + +{ + local $@; + eval { Test::Leaner::tap_stream($memory_stream) }; + is $@, '', 'tap_stream($fh) does not croak'; +} + +{ + local $@; + $buf = ''; + seek $memory_stream, 0, 0; + eval { Test::Leaner::fail() }; + is $@, '', 'fail() does not croak'; + is $buf, "not ok 1\n", 'fail() produces the correct TAP code'; +} + +{ + local $@; + $buf = ''; + seek $memory_stream, 0, 0; + eval { Test::Leaner::fail('this is a comment') }; + is $@, '', 'fail("comment") does not croak'; + is $buf, "not ok 2 - this is a comment\n", + 'fail("comment") produces the correct TAP code'; +}