File: 1.t

package info (click to toggle)
libsyntax-keyword-gather-perl 1.003002-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 120 kB
  • sloc: perl: 135; makefile: 2
file content (27 lines) | stat: -rwxr-xr-x 706 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
#!perl
use strict;
use warnings;

use Test::More 'no_plan';
BEGIN { use_ok('Syntax::Keyword::Gather') };

ok eq_array(
   [gather { take $_ for 1..10; take 99 }],
   [1..10, 99],
), 'basic gather works' ;
ok eq_array(
   [gather { take $_ for 1..10; take 99 unless gathered }],
   [1..10],
), 'gathered works in boolean context (true)';
ok eq_array(
   [gather { take 99 unless gathered }],
   [99],
), 'gathered works in boolean context (false)';

ok eq_array(
   [gather { take $_ for 1..10; pop @{+gathered} }],
   [1..9]
), 'gathered allows modification of underlying data';

ok(!eval{ take 'two' }, 'take does not work without gather');
ok(!eval{ gathered }, 'gathered does not work without gather');