File: while_num.t

package info (click to toggle)
libsmart-comments-perl 1.000005-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 200 kB
  • ctags: 12
  • sloc: perl: 302; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 676 bytes parent folder | download
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
use Smart::Comments;
use Test::More 'no_plan';

close *STDERR;
my $STDERR = q{};
open *STDERR, '>', \$STDERR;

my $count = 0;

LABEL:

while ($count < 100) {    ### while:===[%]   done (%)
    $count++;
}

close *STDERR;
open *STDERR, '>-';

my $prev_count = -1;
sub test_format_and_incr {
    my ($n, $output) = @_;
    subtest "Iteration $n" => sub {
        ok $output =~ m/while:=*\[(\d+)\]\s+done \(\1\)/ => 'Correct format';
        my $count = $1;
        cmp_ok $count, '>', $prev_count  => 'Correctly incremented';
        $prev_count = $count;
    };
}

my @outputs = grep /\S/, split /\r/, $STDERR;

for my $n (0..5) {
    test_format_and_incr($n, $outputs[$n]);
}