|
Packit Service |
d987f3 |
#!/usr/bin/perl
|
|
Packit Service |
d987f3 |
#
|
|
Packit Service |
d987f3 |
# Basic test suite for the Term::ANSIColor Perl module.
|
|
Packit Service |
d987f3 |
#
|
|
Packit Service |
d987f3 |
# Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2009, 2010, 2012, 2014
|
|
Packit Service |
d987f3 |
# Russ Allbery <rra@cpan.org>
|
|
Packit Service |
d987f3 |
#
|
|
Packit Service |
d987f3 |
# This program is free software; you may redistribute it and/or modify it
|
|
Packit Service |
d987f3 |
# under the same terms as Perl itself.
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
use strict;
|
|
Packit Service |
d987f3 |
use warnings;
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
use Test::More tests => 152;
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Load the module.
|
|
Packit Service |
d987f3 |
BEGIN {
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_ALIASES};
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_DISABLED};
|
|
Packit Service |
d987f3 |
use_ok('Term::ANSIColor',
|
|
Packit Service |
d987f3 |
qw(:pushpop color colored uncolor colorstrip colorvalid));
|
|
Packit Service |
d987f3 |
}
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Various basic tests.
|
|
Packit Service |
d987f3 |
is(color('blue on_green', 'bold'), "\e[34;42;1m", 'Simple attributes');
|
|
Packit Service |
d987f3 |
is(colored('testing', 'blue', 'bold'), "\e[34;1mtesting\e[0m", 'colored');
|
|
Packit Service |
d987f3 |
is((BLUE BOLD 'testing'), "\e[34m\e[1mtesting", 'Constants');
|
|
Packit Service |
d987f3 |
is(join(q{}, BLUE, BOLD, 'testing'),
|
|
Packit Service |
d987f3 |
"\e[34m\e[1mtesting", 'Constants with commas');
|
|
Packit Service |
d987f3 |
is((BLUE 'test', 'ing'), "\e[34mtesting", 'Constants with multiple strings');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test case variations on attributes.
|
|
Packit Service |
d987f3 |
is(color('Blue BOLD', 'on_GReeN'), "\e[34;1;42m", 'Attribute case');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# color should return undef if there were no attributes.
|
|
Packit Service |
d987f3 |
is(color(), undef, 'color returns undef with no attributes');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Autoreset after the end of a command string.
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTORESET = 1;
|
|
Packit Service |
d987f3 |
is((BLUE BOLD 'testing'), "\e[34m\e[1mtesting\e[0m\e[0m", 'AUTORESET');
|
|
Packit Service |
d987f3 |
is((BLUE BOLD, 'te', 'st'), "\e[34m\e[1mtest\e[0m", 'AUTORESET with commas');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTORESET = 0;
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Reset after each line terminator.
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::EACHLINE = "\n";
|
|
Packit Service |
d987f3 |
is(colored("test\n\ntest", 'bold'),
|
|
Packit Service |
d987f3 |
"\e[1mtest\e[0m\n\n\e[1mtest\e[0m", 'EACHLINE');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::EACHLINE = "\r\n";
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
colored("test\ntest\r\r\n\r\n", 'bold'),
|
|
Packit Service |
d987f3 |
"\e[1mtest\ntest\r\e[0m\r\n\r\n",
|
|
Packit Service |
d987f3 |
'EACHLINE with multiple delimiters'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::EACHLINE = "\n";
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
colored(['bold', 'on_green'], "test\n", "\n", 'test'),
|
|
Packit Service |
d987f3 |
"\e[1;42mtest\e[0m\n\n\e[1;42mtest\e[0m",
|
|
Packit Service |
d987f3 |
'colored with reference to array'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Basic tests for uncolor.
|
|
Packit Service |
d987f3 |
is_deeply([uncolor('1;42', "\e[m", q{}, "\e[0m")],
|
|
Packit Service |
d987f3 |
[qw(bold on_green clear)], 'uncolor');
|
|
Packit Service |
d987f3 |
is_deeply([uncolor("\e[01m")], ['bold'], 'uncolor("\\e[01m")');
|
|
Packit Service |
d987f3 |
is_deeply([uncolor("\e[m")], [], 'uncolor("\\e[m")');
|
|
Packit Service |
d987f3 |
is_deeply([uncolor(q{})], [], 'uncolor("")');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Several tests for ANSI_COLORS_DISABLED.
|
|
Packit Service |
d987f3 |
local $ENV{ANSI_COLORS_DISABLED} = 1;
|
|
Packit Service |
d987f3 |
is(color('blue'), q{}, 'color support for ANSI_COLORS_DISABLED');
|
|
Packit Service |
d987f3 |
is(colored('testing', 'blue', 'on_red'),
|
|
Packit Service |
d987f3 |
'testing', 'colored support for ANSI_COLORS_DISABLED');
|
|
Packit Service |
d987f3 |
is((GREEN 'testing'), 'testing', 'Constant support for ANSI_COLORS_DISABLED');
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_DISABLED};
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Earlier versions of Term::ANSIColor didn't support ANSI_COLORS_DISABLED if
|
|
Packit Service |
d987f3 |
# the constant had been created before the environment variable was set. Test
|
|
Packit Service |
d987f3 |
# all the ones we're going to use to get full test coverage.
|
|
Packit Service |
d987f3 |
local $ENV{ANSI_COLORS_DISABLED} = 1;
|
|
Packit Service |
d987f3 |
is((BLUE 'testing'), 'testing', 'ANSI_COLORS_DISABLED with existing constant');
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_DISABLED};
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# If ANSI_COLORS_DISABLED is set to a false value or the empty string, it
|
|
Packit Service |
d987f3 |
# should not take effect.
|
|
Packit Service |
d987f3 |
local $ENV{ANSI_COLORS_DISABLED} = 0;
|
|
Packit Service |
d987f3 |
is(color('bold'), "\e[1m", 'ANSI_COLORS_DISABLED must be true');
|
|
Packit Service |
d987f3 |
is((BOLD), "\e[1m", '...likewise for constants');
|
|
Packit Service |
d987f3 |
local $ENV{ANSI_COLORS_DISABLED} = q{};
|
|
Packit Service |
d987f3 |
is(color('bold'), "\e[1m", '...likewise when set to an empty string');
|
|
Packit Service |
d987f3 |
is((BOLD), "\e[1m", '...likewise for constants');
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_DISABLED};
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Make sure DARK is exported. This was omitted in versions prior to 1.07.
|
|
Packit Service |
d987f3 |
is((DARK 'testing'), "\e[2mtesting", 'DARK');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Check faint as a synonym for dark.
|
|
Packit Service |
d987f3 |
is(colored('test', 'faint'), "\e[2mtest\e[0m", 'colored supports faint');
|
|
Packit Service |
d987f3 |
is((FAINT 'test'), "\e[2mtest", '...and the FAINT constant works');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test bright color support.
|
|
Packit Service |
d987f3 |
is(color('bright_red'), "\e[91m", 'Bright red is supported');
|
|
Packit Service |
d987f3 |
is((BRIGHT_RED 'test'), "\e[91mtest", '...and as a constant');
|
|
Packit Service |
d987f3 |
is(color('on_bright_red'), "\e[101m", '...as is on bright red');
|
|
Packit Service |
d987f3 |
is((ON_BRIGHT_RED 'test'), "\e[101mtest", '...and as a constant');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test italic, which was added in 3.02.
|
|
Packit Service |
d987f3 |
is(color('italic'), "\e[3m", 'Italic is supported');
|
|
Packit Service |
d987f3 |
is((ITALIC 'test'), "\e[3mtest", '...and as a constant');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test colored with 0 and EACHLINE. Regression test for an incorrect use of a
|
|
Packit Service |
d987f3 |
# truth check.
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::EACHLINE = "\n";
|
|
Packit Service |
d987f3 |
is(colored('0', 'blue', 'bold'),
|
|
Packit Service |
d987f3 |
"\e[34;1m0\e[0m", 'colored with 0 and EACHLINE');
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
colored("0\n0\n\n", 'blue', 'bold'),
|
|
Packit Service |
d987f3 |
"\e[34;1m0\e[0m\n\e[34;1m0\e[0m\n\n",
|
|
Packit Service |
d987f3 |
'colored with 0, EACHLINE, and multiple lines'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test colored with the empty string and EACHLINE.
|
|
Packit Service |
d987f3 |
is(colored(q{}, 'blue', 'bold'), q{}, 'colored w/empty string and EACHLINE');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test push and pop support.
|
|
Packit Service |
d987f3 |
is((PUSHCOLOR RED ON_GREEN 'text'),
|
|
Packit Service |
d987f3 |
"\e[31m\e[42mtext", 'PUSHCOLOR does not break constants');
|
|
Packit Service |
d987f3 |
is((PUSHCOLOR BLUE 'text'), "\e[34mtext", '...and adding another level');
|
|
Packit Service |
d987f3 |
is((RESET BLUE 'text'), "\e[0m\e[34mtext", '...and using reset');
|
|
Packit Service |
d987f3 |
is((POPCOLOR 'text'), "\e[31m\e[42mtext", '...and POPCOLOR works');
|
|
Packit Service |
d987f3 |
is((LOCALCOLOR GREEN ON_BLUE 'text'),
|
|
Packit Service |
d987f3 |
"\e[32m\e[44mtext\e[31m\e[42m", 'LOCALCOLOR');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTOLOCAL = 1;
|
|
Packit Service |
d987f3 |
is((BLUE 'text'), "\e[34mtext\e[31m\e[42m", 'AUTOLOCAL');
|
|
Packit Service |
d987f3 |
is((BLUE 'te', 'xt'), "\e[34mtext\e[31m\e[42m", 'AUTOLOCAL with commas');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTOLOCAL = 0;
|
|
Packit Service |
d987f3 |
is((POPCOLOR 'text'), "\e[0mtext", 'POPCOLOR with empty stack');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# If AUTOLOCAL and AUTORESET are both set, the former takes precedence.
|
|
Packit Service |
d987f3 |
is((PUSHCOLOR RED ON_GREEN 'text'),
|
|
Packit Service |
d987f3 |
"\e[31m\e[42mtext", 'Push some colors onto the stack');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTOLOCAL = 1;
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTORESET = 1;
|
|
Packit Service |
d987f3 |
is((BLUE 'text'), "\e[34mtext\e[31m\e[42m", 'AUTOLOCAL overrides AUTORESET');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTOLOCAL = 0;
|
|
Packit Service |
d987f3 |
is((BLUE 'text'), "\e[34mtext\e[0m", 'AUTORESET works with stacked colors');
|
|
Packit Service |
d987f3 |
is((POPCOLOR 'text'), "\e[0mtext\e[0m", 'POPCOLOR with empty stack');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTORESET = 0;
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test push and pop support with the syntax from the original openmethods.com
|
|
Packit Service |
d987f3 |
# submission, which uses a different coding style.
|
|
Packit Service |
d987f3 |
is(PUSHCOLOR(RED ON_GREEN), "\e[31m\e[42m", 'PUSHCOLOR with explict argument');
|
|
Packit Service |
d987f3 |
is(PUSHCOLOR(BLUE), "\e[34m", '...and another explicit argument');
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
RESET . BLUE . 'text',
|
|
Packit Service |
d987f3 |
"\e[0m\e[34mtext",
|
|
Packit Service |
d987f3 |
'...and constants with concatenation'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
POPCOLOR . 'text',
|
|
Packit Service |
d987f3 |
"\e[31m\e[42mtext",
|
|
Packit Service |
d987f3 |
'...and POPCOLOR works without an argument'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
LOCALCOLOR(GREEN . ON_BLUE . 'text'),
|
|
Packit Service |
d987f3 |
"\e[32m\e[44mtext\e[31m\e[42m",
|
|
Packit Service |
d987f3 |
'LOCALCOLOR with two arguments'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
is(POPCOLOR . 'text', "\e[0mtext", 'POPCOLOR with no arguments');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Prior to Term::ANSIColor, PUSHCOLOR, unlike all other constants, didn't take
|
|
Packit Service |
d987f3 |
# an array, so it could lose colors in some syntax.
|
|
Packit Service |
d987f3 |
is(PUSHCOLOR(RED, ON_GREEN), "\e[31m\e[42m", 'PUSHCOLOR with two arguments');
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
LOCALCOLOR(GREEN, 'text'),
|
|
Packit Service |
d987f3 |
"\e[32mtext\e[31m\e[42m",
|
|
Packit Service |
d987f3 |
'LOCALCOLOR with two arguments'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
is(POPCOLOR(BOLD, 'text'), "\e[0m\e[1mtext", 'POPCOLOR with two arguments');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test colorstrip.
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
colorstrip("\e[1mBold \e[31;42mon green\e[0m\e[m"),
|
|
Packit Service |
d987f3 |
'Bold on green',
|
|
Packit Service |
d987f3 |
'Basic color stripping'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
is(colorstrip("\e[1m", 'bold', "\e[0m"),
|
|
Packit Service |
d987f3 |
'bold', 'Color stripping across multiple strings');
|
|
Packit Service |
d987f3 |
is_deeply(
|
|
Packit Service |
d987f3 |
[colorstrip("\e[1m", 'bold', "\e[0m")],
|
|
Packit Service |
d987f3 |
[q{}, 'bold', q{}],
|
|
Packit Service |
d987f3 |
'...and in an array context'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
is(colorstrip("foo\e[1m", 'bar', "baz\e[0m"),
|
|
Packit Service |
d987f3 |
'foobarbaz', '...and proper joining in scalar context');
|
|
Packit Service |
d987f3 |
is(
|
|
Packit Service |
d987f3 |
colorstrip("\e[2cSome other code\e and stray [0m stuff"),
|
|
Packit Service |
d987f3 |
"\e[2cSome other code\e and stray [0m stuff",
|
|
Packit Service |
d987f3 |
'colorstrip does not remove non-color stuff'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test colorvalid.
|
|
Packit Service |
d987f3 |
ok(
|
|
Packit Service |
d987f3 |
colorvalid('blue bold dark', 'blink on_green'),
|
|
Packit Service |
d987f3 |
'colorvalid returns true for valid attributes'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
ok(!colorvalid('green orange'), '...and false for invalid attributes');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test error handling in color.
|
|
Packit Service |
d987f3 |
my $output = eval { color('chartreuse') };
|
|
Packit Service |
d987f3 |
is($output, undef, 'color on unknown color name fails');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A Invalid [ ] attribute [ ] name [ ] chartreuse [ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'...with the right error'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test error handling in colored.
|
|
Packit Service |
d987f3 |
$output = eval { colored('Stuff', 'chartreuse') };
|
|
Packit Service |
d987f3 |
is($output, undef, 'colored on unknown color name fails');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A Invalid [ ] attribute [ ] name [ ] chartreuse [ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'...with the right error'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test error handling in uncolor.
|
|
Packit Service |
d987f3 |
$output = eval { uncolor "\e[28m" };
|
|
Packit Service |
d987f3 |
is($output, undef, 'uncolor on unknown color code fails');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A No [ ] name [ ] for [ ] escape [ ] sequence [ ] 28 [ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'...with the right error'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
$output = eval { uncolor "\e[foom" };
|
|
Packit Service |
d987f3 |
is($output, undef, 'uncolor on bad escape sequence fails');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A Bad [ ] escape [ ] sequence [ ] foo [ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'...with the right error'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Test error reporting when calling unrecognized Term::ANSIColor subs that go
|
|
Packit Service |
d987f3 |
# through AUTOLOAD.
|
|
Packit Service |
d987f3 |
ok(!eval { Term::ANSIColor::RSET() }, 'Running invalid constant');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A undefined [ ] subroutine [ ] \&Term::ANSIColor::RSET [ ] called
|
|
Packit Service |
d987f3 |
[ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'Correct error from an attribute that is not defined'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
ok(!eval { Term::ANSIColor::reset() }, 'Running invalid sub');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A undefined [ ] subroutine [ ] \&Term::ANSIColor::reset [ ] called
|
|
Packit Service |
d987f3 |
[ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'Correct error from a lowercase attribute'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Ensure that we still get proper error reporting for unknown constants when
|
|
Packit Service |
d987f3 |
# when colors are disabled.
|
|
Packit Service |
d987f3 |
local $ENV{ANSI_COLORS_DISABLED} = 1;
|
|
Packit Service |
d987f3 |
eval { Term::ANSIColor::RSET() };
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A undefined [ ] subroutine [ ] \&Term::ANSIColor::RSET [ ] called
|
|
Packit Service |
d987f3 |
[ ] at [ ] }xms,
|
|
Packit Service |
d987f3 |
'Correct error from undefined attribute with disabled colors'
|
|
Packit Service |
d987f3 |
);
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_DISABLED};
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# These are somewhat redundant, but they ensure we test all the branches in
|
|
Packit Service |
d987f3 |
# our generated constant subs so that we can use Test::Strict to check test
|
|
Packit Service |
d987f3 |
# suite coverage.
|
|
Packit Service |
d987f3 |
is((BOLD 't'), "\e[1mt", 'Basic constant works for BOLD');
|
|
Packit Service |
d987f3 |
is((BLUE 't'), "\e[34mt", '...and for BLUE');
|
|
Packit Service |
d987f3 |
is((GREEN 't'), "\e[32mt", '...and for GREEN');
|
|
Packit Service |
d987f3 |
is((DARK 't'), "\e[2mt", '...and for DARK');
|
|
Packit Service |
d987f3 |
is((FAINT 't'), "\e[2mt", '...and for FAINT');
|
|
Packit Service |
d987f3 |
is((BRIGHT_RED 't'), "\e[91mt", '...and for BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ON_BRIGHT_RED 't'), "\e[101mt", '...and for ON_BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ITALIC 't'), "\e[3mt", '...and for ITALIC');
|
|
Packit Service |
d987f3 |
is((RED 't'), "\e[31mt", '...and for RED');
|
|
Packit Service |
d987f3 |
is((ON_GREEN 't'), "\e[42mt", '...and for ON_GREEN');
|
|
Packit Service |
d987f3 |
is((ON_BLUE 't'), "\e[44mt", '...and for ON_BLUE');
|
|
Packit Service |
d987f3 |
is((RESET 't'), "\e[0mt", '...and for RESET');
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Do the same for disabled colors.
|
|
Packit Service |
d987f3 |
local $ENV{ANSI_COLORS_DISABLED} = 1;
|
|
Packit Service |
d987f3 |
is(BOLD, q{}, 'ANSI_COLORS_DISABLED works for BOLD');
|
|
Packit Service |
d987f3 |
is(BLUE, q{}, '...and for BLUE');
|
|
Packit Service |
d987f3 |
is(GREEN, q{}, '...and for GREEN');
|
|
Packit Service |
d987f3 |
is(DARK, q{}, '...and for DARK');
|
|
Packit Service |
d987f3 |
is(FAINT, q{}, '...and for FAINT');
|
|
Packit Service |
d987f3 |
is(BRIGHT_RED, q{}, '...and for BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is(ON_BRIGHT_RED, q{}, '...and for ON_BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is(ITALIC, q{}, '...and for ITALIC');
|
|
Packit Service |
d987f3 |
is(RED, q{}, '...and for RED');
|
|
Packit Service |
d987f3 |
is(ON_GREEN, q{}, '...and for ON_GREEN');
|
|
Packit Service |
d987f3 |
is(ON_BLUE, q{}, '...and for ON_BLUE');
|
|
Packit Service |
d987f3 |
is(RESET, q{}, '...and for RESET');
|
|
Packit Service |
d987f3 |
delete $ENV{ANSI_COLORS_DISABLED};
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Do the same for AUTORESET.
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTORESET = 1;
|
|
Packit Service |
d987f3 |
is((BOLD 't'), "\e[1mt\e[0m", 'AUTORESET works for BOLD');
|
|
Packit Service |
d987f3 |
is((BLUE 't'), "\e[34mt\e[0m", '...and for BLUE');
|
|
Packit Service |
d987f3 |
is((GREEN 't'), "\e[32mt\e[0m", '...and for GREEN');
|
|
Packit Service |
d987f3 |
is((DARK 't'), "\e[2mt\e[0m", '...and for DARK');
|
|
Packit Service |
d987f3 |
is((FAINT 't'), "\e[2mt\e[0m", '...and for FAINT');
|
|
Packit Service |
d987f3 |
is((BRIGHT_RED 't'), "\e[91mt\e[0m", '...and for BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ON_BRIGHT_RED 't'), "\e[101mt\e[0m", '...and for ON_BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ITALIC 't'), "\e[3mt\e[0m", '...and for ITALIC');
|
|
Packit Service |
d987f3 |
is((RED 't'), "\e[31mt\e[0m", '...and for RED');
|
|
Packit Service |
d987f3 |
is((ON_GREEN 't'), "\e[42mt\e[0m", '...and for ON_GREEN');
|
|
Packit Service |
d987f3 |
is((ON_BLUE 't'), "\e[44mt\e[0m", '...and for ON_BLUE');
|
|
Packit Service |
d987f3 |
is((RESET 't'), "\e[0mt\e[0m", '...and for RESET');
|
|
Packit Service |
d987f3 |
is((BOLD), "\e[1m", 'AUTORESET without text for BOLD');
|
|
Packit Service |
d987f3 |
is((BLUE), "\e[34m", '...and for BLUE');
|
|
Packit Service |
d987f3 |
is((GREEN), "\e[32m", '...and for GREEN');
|
|
Packit Service |
d987f3 |
is((DARK), "\e[2m", '...and for DARK');
|
|
Packit Service |
d987f3 |
is((FAINT), "\e[2m", '...and for FAINT');
|
|
Packit Service |
d987f3 |
is((BRIGHT_RED), "\e[91m", '...and for BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ON_BRIGHT_RED), "\e[101m", '...and for ON_BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ITALIC), "\e[3m", '...and for ITALIC');
|
|
Packit Service |
d987f3 |
is((RED), "\e[31m", '...and for RED');
|
|
Packit Service |
d987f3 |
is((ON_GREEN), "\e[42m", '...and for ON_GREEN');
|
|
Packit Service |
d987f3 |
is((ON_BLUE), "\e[44m", '...and for ON_BLUE');
|
|
Packit Service |
d987f3 |
is((RESET), "\e[0m", '...and for RESET');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTORESET = 0;
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Do the same for AUTOLOCAL.
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTOLOCAL = 1;
|
|
Packit Service |
d987f3 |
is((BOLD 't'), "\e[1mt\e[0m", 'AUTOLOCAL works for BOLD');
|
|
Packit Service |
d987f3 |
is((BLUE 't'), "\e[34mt\e[0m", '...and for BLUE');
|
|
Packit Service |
d987f3 |
is((GREEN 't'), "\e[32mt\e[0m", '...and for GREEN');
|
|
Packit Service |
d987f3 |
is((DARK 't'), "\e[2mt\e[0m", '...and for DARK');
|
|
Packit Service |
d987f3 |
is((FAINT 't'), "\e[2mt\e[0m", '...and for FAINT');
|
|
Packit Service |
d987f3 |
is((BRIGHT_RED 't'), "\e[91mt\e[0m", '...and for BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ON_BRIGHT_RED 't'), "\e[101mt\e[0m", '...and for ON_BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ITALIC 't'), "\e[3mt\e[0m", '...and for ITALIC');
|
|
Packit Service |
d987f3 |
is((RED 't'), "\e[31mt\e[0m", '...and for RED');
|
|
Packit Service |
d987f3 |
is((ON_GREEN 't'), "\e[42mt\e[0m", '...and for ON_GREEN');
|
|
Packit Service |
d987f3 |
is((ON_BLUE 't'), "\e[44mt\e[0m", '...and for ON_BLUE');
|
|
Packit Service |
d987f3 |
is((RESET 't'), "\e[0mt\e[0m", '...and for RESET');
|
|
Packit Service |
d987f3 |
is((BOLD), "\e[1m", 'AUTOLOCAL without text for BOLD');
|
|
Packit Service |
d987f3 |
is((BLUE), "\e[34m", '...and for BLUE');
|
|
Packit Service |
d987f3 |
is((GREEN), "\e[32m", '...and for GREEN');
|
|
Packit Service |
d987f3 |
is((DARK), "\e[2m", '...and for DARK');
|
|
Packit Service |
d987f3 |
is((FAINT), "\e[2m", '...and for FAINT');
|
|
Packit Service |
d987f3 |
is((BRIGHT_RED), "\e[91m", '...and for BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ON_BRIGHT_RED), "\e[101m", '...and for ON_BRIGHT_RED');
|
|
Packit Service |
d987f3 |
is((ITALIC), "\e[3m", '...and for ITALIC');
|
|
Packit Service |
d987f3 |
is((RED), "\e[31m", '...and for RED');
|
|
Packit Service |
d987f3 |
is((ON_GREEN), "\e[42m", '...and for ON_GREEN');
|
|
Packit Service |
d987f3 |
is((ON_BLUE), "\e[44m", '...and for ON_BLUE');
|
|
Packit Service |
d987f3 |
is((RESET), "\e[0m", '...and for RESET');
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::AUTOLOCAL = 0;
|
|
Packit Service |
d987f3 |
|
|
Packit Service |
d987f3 |
# Force an internal error inside the AUTOLOAD stub by creating an attribute
|
|
Packit Service |
d987f3 |
# that will generate a syntax error. This is just for coverage purposes.
|
|
Packit Service |
d987f3 |
# Disable warnings since our syntax error will spew otherwise.
|
|
Packit Service |
d987f3 |
local $SIG{__WARN__} = sub { };
|
|
Packit Service |
d987f3 |
$Term::ANSIColor::ATTRIBUTES{yellow} = q{'ERROR'};
|
|
Packit Service |
d987f3 |
ok(!eval { YELLOW 't' }, 'Caught internal AUTOLOAD error');
|
|
Packit Service |
d987f3 |
like(
|
|
Packit Service |
d987f3 |
$@,
|
|
Packit Service |
d987f3 |
qr{ \A failed [ ] to [ ] generate [ ] constant [ ] YELLOW: [ ] }xms,
|
|
Packit Service |
d987f3 |
'...with correct error message'
|
|
Packit Service |
d987f3 |
);
|