11 use Test::Leaner::TestHelper;
14 capture_to_buffer $buf
15 or plan skip_all =>'perl 5.8 required to test ok() failing';
21 my $ret = eval { Test::Leaner::ok(0) };
22 is $@, '', 'ok(0) does not croak';
23 ok !$ret, 'ok(0) returns false';
24 is $buf, "not ok 1\n", 'ok(0) produces the correct TAP code';
29 my $ret = eval { Test::Leaner::ok(undef) };
30 is $@, '', 'ok(undef) does not croak';
31 ok !$ret, 'ok(undef) returns false';
32 is $buf, "not ok 2\n", 'ok(undef) produces the correct TAP code';
37 my $ret = eval { Test::Leaner::ok(!1) };
38 is $@, '', 'ok(false) does not croak';
39 ok !$ret, 'ok(false) returns false';
40 is $buf, "not ok 3\n", 'ok(false) produces the correct TAP code';
45 my $ret = eval { Test::Leaner::ok(0, 'this is a comment') };
46 is $@, '', 'ok(0, "comment") does not croak';
47 ok !$ret, 'ok(0, "comment") returns false';
48 is $buf, "not ok 4 - this is a comment\n",
49 'ok(0, "comment") produces the correct TAP code';
53 package Test::Leaner::TestOverload::AlwaysFalse;
55 use overload 'bool' => sub { !1 };
57 sub new { bless { }, shift }
60 my $z = Test::Leaner::TestOverload::AlwaysFalse->new;
64 my $ret = eval { Test::Leaner::ok($z) };
65 is $@, '', 'ok($overloaded_false) does not croak';
66 ok !$ret, 'ok($overloaded_false) returns false';
67 is $buf, "not ok 5\n", 'ok($overloaded_false) produces the correct TAP code';