File: any.pm

package info (click to toggle)
liblist-moreutils-xs-perl 0.430-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,116 kB
  • sloc: perl: 9,038; ansic: 159; makefile: 3
file content (30 lines) | stat: -rw-r--r-- 658 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

use Test::More;
use Test::LMU;

# Normal cases
my @list = (1 .. 10000);
is_true(any { $_ == 5000 } @list);
is_true(any { $_ == 5000 } 1 .. 10000);
is_true(any { defined } @list);
is_false(any { not defined } @list);
is_true(any { not defined } undef);
is_false(any {});

leak_free_ok(
    any => sub {
        my $ok  = any { $_ == 5000 } @list;
        my $ok2 = any { $_ == 5000 } 1 .. 10000;
    }
);
leak_free_ok(
    'any with a coderef that dies' => sub {
        # This test is from Kevin Ryde; see RT#48669
        eval {
            my $ok = any { die } 1;
        };
    }
);
is_dying('any without sub' => sub { &any(42, 4711); });

done_testing;