1#!perl
2
3use strict ("subs", "vars", "refs");
4use warnings ("all");
5use lib ("t/lib");
6use List::MoreUtils::XS (":all");
7
8
9use Test::More;
10use Test::LMU;
11
12# The null set should return zero
13my $null_scalar = true {};
14my @null_list   = true {};
15is($null_scalar, 0, 'true(null) returns undef');
16is_deeply(\@null_list, [0], 'true(null) returns undef');
17
18# Normal cases
19my @list = (1 .. 10000);
20is(10000, true { defined } @list);
21is(0,     true { not defined } @list);
22is(1,     true { $_ == 5000 } @list);
23
24leak_free_ok(
25    true => sub {
26        my $n  = true { $_ == 5000 } @list;
27        my $n2 = true { $_ == 5000 } 1 .. 10000;
28    }
29);
30is_dying('true without sub' => sub { &true(42, 4711); });
31
32done_testing;
33
34
35