xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Harness/t/console.t (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1use strict;
2use lib 't/lib';
3use Test::More;
4use TAP::Formatter::Console;
5
6my @schedule;
7
8BEGIN {
9    @schedule = (
10        {   method => '_range',
11            in     => sub {qw/2 7 1 3 10 9/},
12            out    => sub {qw/1-3 7 9-10/},
13            name   => '... and it should return numbers as ranges'
14        },
15        {   method => '_balanced_range',
16            in     => sub { 7, qw/2 7 1 3 10 9/ },
17            out    => sub { '1-3, 7', '9-10' },
18            name   => '... and it should return numbers as ranges'
19        },
20    );
21
22    plan tests => @schedule * 3;
23}
24
25for my $test (@schedule) {
26    my $name = $test->{name};
27    my $cons = TAP::Formatter::Console->new;
28    isa_ok $cons, 'TAP::Formatter::Console';
29    my $method = $test->{method};
30    can_ok $cons, $method;
31    is_deeply [ $cons->$method( $test->{in}->() ) ], [ $test->{out}->() ],
32      $name;
33}
34
35#### Color tests ####
36
37package Colorizer;
38
39sub new { bless {}, shift }
40sub can_color {1}
41
42sub set_color {
43    my ( $self, $output, $color ) = @_;
44    $output->("[[$color]]");
45}
46
47package main;
48