summaryrefslogtreecommitdiff
path: root/cpan/Test-Harness/t/console.t
blob: 32f5db62ac9ac43c28de8bb3e9547d285af37887 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
use strict;
use lib 't/lib';
use Test::More;
use TAP::Formatter::Console;

my @schedule;

BEGIN {
    @schedule = (
        {   method => '_range',
            in     => sub {qw/2 7 1 3 10 9/},
            out    => sub {qw/1-3 7 9-10/},
            name   => '... and it should return numbers as ranges'
        },
        {   method => '_balanced_range',
            in     => sub { 7, qw/2 7 1 3 10 9/ },
            out    => sub { '1-3, 7', '9-10' },
            name   => '... and it should return numbers as ranges'
        },
    );

    plan tests => @schedule * 3;
}

for my $test (@schedule) {
    my $name = $test->{name};
    my $cons = TAP::Formatter::Console->new;
    isa_ok $cons, 'TAP::Formatter::Console';
    my $method = $test->{method};
    can_ok $cons, $method;
    is_deeply [ $cons->$method( $test->{in}->() ) ], [ $test->{out}->() ],
      $name;
}

#### Color tests ####

package Colorizer;

sub new { bless {}, shift }
sub can_color {1}

sub set_color {
    my ( $self, $output, $color ) = @_;
    $output->("[[$color]]");
}

package main;