File: 04none.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 (32 lines) | stat: -rw-r--r-- 738 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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use List::Keywords 'none';

# Basic true/false testing
ok( !(none { $_ > 10 } 1 .. 20), 'list contains a value above ten' );
ok(  (none { $_ > 10 } 1 .. 9), 'list does not contain a value above ten' );

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

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

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

done_testing;