File: false.t

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 (34 lines) | stat: -rw-r--r-- 719 bytes parent folder | download | duplicates (3)
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
31
32
33
34
#!perl

use strict ("subs", "vars", "refs");
use warnings ("all");
use lib ("t/lib");
use List::MoreUtils::XS (":all");


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

# The null set should return zero
my $null_scalar = false {};
my @null_list   = false {};
is($null_scalar, 0, 'false(null) returns undef');
is_deeply(\@null_list, [0], 'false(null) returns undef');

# Normal cases
my @list = (1 .. 10000);
is(10000, false { not defined } @list);
is(0,     false { defined } @list);
is(1,     false { $_ > 1 } @list);

leak_free_ok(
    false => sub {
        my $n  = false { $_ == 5000 } @list;
        my $n2 = false { $_ == 5000 } 1 .. 10000;
    }
);
is_dying('false without sub' => sub { &false(42, 4711); });

done_testing;