File: 05notall.t

package info (click to toggle)
liblist-keywords-perl 0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 200 kB
  • sloc: perl: 467; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use List::Keywords 'notall';

# Basic true/false testing
ok(  (notall { $_ < 10 } 1 .. 20), 'notall list values below ten' );
ok( !(notall { $_ < 10 } 1 .. 9), 'not notall list values below ten' );

# notall empty list is true
{
   my $invoked;
   my $ret = notall { $invoked++ } ();
   ok( defined $ret, 'notall on empty list is defined' );
   ok( !$ret, 'notall on empty list is false' );
   ok( !$invoked, 'notall on empty list did not invoke block' );
}

# notall failure yields scalar in list context
{
   my @ret;
   @ret = notall { $_ > 10 } 1 .. 9;
   ok( !!@ret, 'notall nothing yielded false in list context' );

   @ret = notall { $_ > 10 } ();
   ok( !!@ret, 'notall nothing yielded false in list context on empty input' );
}

done_testing;