Help language development. Donate to The Perl Foundation

List::Util zef:lizmat last updated on 2021-09-09

t/any-all.t
use v6.*;

use List::Util <any all notall none>;
use Test;

plan 16;

ok defined(&any),    'any defined';
ok defined(&all),    'all defined';
ok defined(&notall), 'notall defined';
ok defined(&none),   'none defined';

ok  (any { $_ == 1 }, 1, 2, 3), 'any true';
ok !(any { $_ == 1 }, 2, 3, 4), 'any false';
ok !(any { 1 }), 'any empty list';

ok  (all { $_ == 1 }, 1, 1, 1), 'all true';
ok !(all { $_ == 1 }, 1, 2, 3), 'all false';
ok  (all { 1 }), 'all empty list';

ok  (notall { $_ == 1 }, 1, 2, 3), 'notall true';
ok !(notall { $_ == 1 }, 1, 1, 1), 'notall false';
ok !(notall { 1 }), 'notall empty list';

ok  (none { $_ == 1 }, 2, 3, 4), 'none true';
ok !(none { $_ == 1 }, 1, 2, 3), 'none false';
ok  (none { 1 }), 'none empty list';

# vim: expandtab shiftwidth=4