]> git.vpit.fr Git - perl/modules/Test-Leaner.git/blob - t/20-ok.t
Test ok() return value, with overloading, and failing
[perl/modules/Test-Leaner.git] / t / 20-ok.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::Leaner tests => 4 + 1 + 2 + 1;
7
8 ok 1;
9 ok !!1,    'ok() test with a description';
10 ok 0.001,  'a float is fine too';
11 ok +{},    'a hash ref is fine too';
12
13 my @array = (undef);
14 ok @array, 'ok() forces scalar context';
15
16 my $ret = ok 1;
17 ok $ret, 'ok(true) returns true';
18
19 {
20  package Test::Leaner::TestOverload::AlwaysFalse;
21
22  use overload 'bool' => sub { 1 };
23
24  sub new { bless { }, shift }
25 }
26
27 my $z = Test::Leaner::TestOverload::AlwaysFalse->new;
28
29 ok $z, 'ok($overloaded_true)';