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