Commit | Line | Data |
---|---|---|
ba5532d7 | 1 | #!/usr/bin/perl |
2e589669 | 2 | # |
ba5532d7 | 3 | # Basic test suite for the Term::ANSIColor Perl module. |
c23d8173 | 4 | # |
5e64492f CBW |
5 | # Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2006, 2009, 2010, 2012, 2014 |
6 | # Russ Allbery <rra@cpan.org> | |
c23d8173 RGS |
7 | # |
8 | # This program is free software; you may redistribute it and/or modify it | |
9 | # under the same terms as Perl itself. | |
e3e5e1ea | 10 | |
c23d8173 | 11 | use strict; |
ba5532d7 | 12 | use warnings; |
e3e5e1ea | 13 | |
ba5532d7 CBW |
14 | use Test::More tests => 152; |
15 | ||
16 | # Load the module. | |
c23d8173 | 17 | BEGIN { |
ba5532d7 | 18 | delete $ENV{ANSI_COLORS_ALIASES}; |
c23d8173 | 19 | delete $ENV{ANSI_COLORS_DISABLED}; |
ba5532d7 CBW |
20 | use_ok('Term::ANSIColor', |
21 | qw(:pushpop color colored uncolor colorstrip colorvalid)); | |
e3e5e1ea GS |
22 | } |
23 | ||
c23d8173 | 24 | # Various basic tests. |
ba5532d7 CBW |
25 | is(color('blue on_green', 'bold'), "\e[34;42;1m", 'Simple attributes'); |
26 | is(colored('testing', 'blue', 'bold'), "\e[34;1mtesting\e[0m", 'colored'); | |
27 | is((BLUE BOLD 'testing'), "\e[34m\e[1mtesting", 'Constants'); | |
28 | is(join(q{}, BLUE, BOLD, 'testing'), | |
29 | "\e[34m\e[1mtesting", 'Constants with commas'); | |
30 | is((BLUE 'test', 'ing'), "\e[34mtesting", 'Constants with multiple strings'); | |
31 | ||
32 | # Test case variations on attributes. | |
33 | is(color('Blue BOLD', 'on_GReeN'), "\e[34;1;42m", 'Attribute case'); | |
34 | ||
35 | # color should return undef if there were no attributes. | |
36 | is(color(), undef, 'color returns undef with no attributes'); | |
37 | ||
38 | # Autoreset after the end of a command string. | |
e3e5e1ea | 39 | $Term::ANSIColor::AUTORESET = 1; |
ba5532d7 CBW |
40 | is((BLUE BOLD 'testing'), "\e[34m\e[1mtesting\e[0m\e[0m", 'AUTORESET'); |
41 | is((BLUE BOLD, 'te', 'st'), "\e[34m\e[1mtest\e[0m", 'AUTORESET with commas'); | |
42 | $Term::ANSIColor::AUTORESET = 0; | |
43 | ||
44 | # Reset after each line terminator. | |
e3e5e1ea | 45 | $Term::ANSIColor::EACHLINE = "\n"; |
ba5532d7 CBW |
46 | is(colored("test\n\ntest", 'bold'), |
47 | "\e[1mtest\e[0m\n\n\e[1mtest\e[0m", 'EACHLINE'); | |
e3e5e1ea | 48 | $Term::ANSIColor::EACHLINE = "\r\n"; |
ba5532d7 CBW |
49 | is( |
50 | colored("test\ntest\r\r\n\r\n", 'bold'), | |
c23d8173 | 51 | "\e[1mtest\ntest\r\e[0m\r\n\r\n", |
ba5532d7 CBW |
52 | 'EACHLINE with multiple delimiters' |
53 | ); | |
f63addff | 54 | $Term::ANSIColor::EACHLINE = "\n"; |
ba5532d7 CBW |
55 | is( |
56 | colored(['bold', 'on_green'], "test\n", "\n", 'test'), | |
c23d8173 | 57 | "\e[1;42mtest\e[0m\n\n\e[1;42mtest\e[0m", |
ba5532d7 CBW |
58 | 'colored with reference to array' |
59 | ); | |
60 | ||
61 | # Basic tests for uncolor. | |
62 | is_deeply([uncolor('1;42', "\e[m", q{}, "\e[0m")], | |
63 | [qw(bold on_green clear)], 'uncolor'); | |
64 | is_deeply([uncolor("\e[01m")], ['bold'], 'uncolor("\\e[01m")'); | |
65 | is_deeply([uncolor("\e[m")], [], 'uncolor("\\e[m")'); | |
66 | is_deeply([uncolor(q{})], [], 'uncolor("")'); | |
110e9fb0 | 67 | |
c23d8173 | 68 | # Several tests for ANSI_COLORS_DISABLED. |
ba5532d7 CBW |
69 | local $ENV{ANSI_COLORS_DISABLED} = 1; |
70 | is(color('blue'), q{}, 'color support for ANSI_COLORS_DISABLED'); | |
71 | is(colored('testing', 'blue', 'on_red'), | |
72 | 'testing', 'colored support for ANSI_COLORS_DISABLED'); | |
73 | is((GREEN 'testing'), 'testing', 'Constant support for ANSI_COLORS_DISABLED'); | |
74 | delete $ENV{ANSI_COLORS_DISABLED}; | |
75 | ||
76 | # Earlier versions of Term::ANSIColor didn't support ANSI_COLORS_DISABLED if | |
77 | # the constant had been created before the environment variable was set. Test | |
78 | # all the ones we're going to use to get full test coverage. | |
79 | local $ENV{ANSI_COLORS_DISABLED} = 1; | |
80 | is((BLUE 'testing'), 'testing', 'ANSI_COLORS_DISABLED with existing constant'); | |
81 | delete $ENV{ANSI_COLORS_DISABLED}; | |
82 | ||
83 | # If ANSI_COLORS_DISABLED is set to a false value or the empty string, it | |
84 | # should not take effect. | |
85 | local $ENV{ANSI_COLORS_DISABLED} = 0; | |
86 | is(color('bold'), "\e[1m", 'ANSI_COLORS_DISABLED must be true'); | |
87 | is((BOLD), "\e[1m", '...likewise for constants'); | |
88 | local $ENV{ANSI_COLORS_DISABLED} = q{}; | |
89 | is(color('bold'), "\e[1m", '...likewise when set to an empty string'); | |
90 | is((BOLD), "\e[1m", '...likewise for constants'); | |
2e589669 RGS |
91 | delete $ENV{ANSI_COLORS_DISABLED}; |
92 | ||
93 | # Make sure DARK is exported. This was omitted in versions prior to 1.07. | |
ba5532d7 | 94 | is((DARK 'testing'), "\e[2mtesting", 'DARK'); |
51da1d85 | 95 | |
cdab9eb9 | 96 | # Check faint as a synonym for dark. |
ba5532d7 CBW |
97 | is(colored('test', 'faint'), "\e[2mtest\e[0m", 'colored supports faint'); |
98 | is((FAINT 'test'), "\e[2mtest", '...and the FAINT constant works'); | |
cdab9eb9 | 99 | |
2c33c767 | 100 | # Test bright color support. |
ba5532d7 CBW |
101 | is(color('bright_red'), "\e[91m", 'Bright red is supported'); |
102 | is((BRIGHT_RED 'test'), "\e[91mtest", '...and as a constant'); | |
103 | is(color('on_bright_red'), "\e[101m", '...as is on bright red'); | |
104 | is((ON_BRIGHT_RED 'test'), "\e[101mtest", '...and as a constant'); | |
2c33c767 | 105 | |
00196a0f | 106 | # Test italic, which was added in 3.02. |
ba5532d7 CBW |
107 | is(color('italic'), "\e[3m", 'Italic is supported'); |
108 | is((ITALIC 'test'), "\e[3mtest", '...and as a constant'); | |
00196a0f | 109 | |
ba5532d7 CBW |
110 | # Test colored with 0 and EACHLINE. Regression test for an incorrect use of a |
111 | # truth check. | |
51da1d85 | 112 | $Term::ANSIColor::EACHLINE = "\n"; |
ba5532d7 CBW |
113 | is(colored('0', 'blue', 'bold'), |
114 | "\e[34;1m0\e[0m", 'colored with 0 and EACHLINE'); | |
115 | is( | |
116 | colored("0\n0\n\n", 'blue', 'bold'), | |
117 | "\e[34;1m0\e[0m\n\e[34;1m0\e[0m\n\n", | |
118 | 'colored with 0, EACHLINE, and multiple lines' | |
119 | ); | |
51da1d85 RGS |
120 | |
121 | # Test colored with the empty string and EACHLINE. | |
ba5532d7 | 122 | is(colored(q{}, 'blue', 'bold'), q{}, 'colored w/empty string and EACHLINE'); |
c23d8173 RGS |
123 | |
124 | # Test push and pop support. | |
ba5532d7 CBW |
125 | is((PUSHCOLOR RED ON_GREEN 'text'), |
126 | "\e[31m\e[42mtext", 'PUSHCOLOR does not break constants'); | |
127 | is((PUSHCOLOR BLUE 'text'), "\e[34mtext", '...and adding another level'); | |
128 | is((RESET BLUE 'text'), "\e[0m\e[34mtext", '...and using reset'); | |
129 | is((POPCOLOR 'text'), "\e[31m\e[42mtext", '...and POPCOLOR works'); | |
130 | is((LOCALCOLOR GREEN ON_BLUE 'text'), | |
131 | "\e[32m\e[44mtext\e[31m\e[42m", 'LOCALCOLOR'); | |
c23d8173 | 132 | $Term::ANSIColor::AUTOLOCAL = 1; |
ba5532d7 CBW |
133 | is((BLUE 'text'), "\e[34mtext\e[31m\e[42m", 'AUTOLOCAL'); |
134 | is((BLUE 'te', 'xt'), "\e[34mtext\e[31m\e[42m", 'AUTOLOCAL with commas'); | |
c23d8173 | 135 | $Term::ANSIColor::AUTOLOCAL = 0; |
ba5532d7 CBW |
136 | is((POPCOLOR 'text'), "\e[0mtext", 'POPCOLOR with empty stack'); |
137 | ||
138 | # If AUTOLOCAL and AUTORESET are both set, the former takes precedence. | |
139 | is((PUSHCOLOR RED ON_GREEN 'text'), | |
140 | "\e[31m\e[42mtext", 'Push some colors onto the stack'); | |
141 | $Term::ANSIColor::AUTOLOCAL = 1; | |
142 | $Term::ANSIColor::AUTORESET = 1; | |
143 | is((BLUE 'text'), "\e[34mtext\e[31m\e[42m", 'AUTOLOCAL overrides AUTORESET'); | |
144 | $Term::ANSIColor::AUTOLOCAL = 0; | |
145 | is((BLUE 'text'), "\e[34mtext\e[0m", 'AUTORESET works with stacked colors'); | |
146 | is((POPCOLOR 'text'), "\e[0mtext\e[0m", 'POPCOLOR with empty stack'); | |
147 | $Term::ANSIColor::AUTORESET = 0; | |
c23d8173 RGS |
148 | |
149 | # Test push and pop support with the syntax from the original openmethods.com | |
150 | # submission, which uses a different coding style. | |
ba5532d7 CBW |
151 | is(PUSHCOLOR(RED ON_GREEN), "\e[31m\e[42m", 'PUSHCOLOR with explict argument'); |
152 | is(PUSHCOLOR(BLUE), "\e[34m", '...and another explicit argument'); | |
153 | is( | |
154 | RESET . BLUE . 'text', | |
155 | "\e[0m\e[34mtext", | |
156 | '...and constants with concatenation' | |
157 | ); | |
158 | is( | |
159 | POPCOLOR . 'text', | |
160 | "\e[31m\e[42mtext", | |
161 | '...and POPCOLOR works without an argument' | |
162 | ); | |
163 | is( | |
164 | LOCALCOLOR(GREEN . ON_BLUE . 'text'), | |
165 | "\e[32m\e[44mtext\e[31m\e[42m", | |
166 | 'LOCALCOLOR with two arguments' | |
167 | ); | |
168 | is(POPCOLOR . 'text', "\e[0mtext", 'POPCOLOR with no arguments'); | |
169 | ||
170 | # Prior to Term::ANSIColor, PUSHCOLOR, unlike all other constants, didn't take | |
171 | # an array, so it could lose colors in some syntax. | |
172 | is(PUSHCOLOR(RED, ON_GREEN), "\e[31m\e[42m", 'PUSHCOLOR with two arguments'); | |
173 | is( | |
174 | LOCALCOLOR(GREEN, 'text'), | |
175 | "\e[32mtext\e[31m\e[42m", | |
176 | 'LOCALCOLOR with two arguments' | |
177 | ); | |
178 | is(POPCOLOR(BOLD, 'text'), "\e[0m\e[1mtext", 'POPCOLOR with two arguments'); | |
b5b25974 RGS |
179 | |
180 | # Test colorstrip. | |
ba5532d7 CBW |
181 | is( |
182 | colorstrip("\e[1mBold \e[31;42mon green\e[0m\e[m"), | |
183 | 'Bold on green', | |
184 | 'Basic color stripping' | |
185 | ); | |
186 | is(colorstrip("\e[1m", 'bold', "\e[0m"), | |
187 | 'bold', 'Color stripping across multiple strings'); | |
188 | is_deeply( | |
189 | [colorstrip("\e[1m", 'bold', "\e[0m")], | |
190 | [q{}, 'bold', q{}], | |
191 | '...and in an array context' | |
192 | ); | |
193 | is(colorstrip("foo\e[1m", 'bar', "baz\e[0m"), | |
194 | 'foobarbaz', '...and proper joining in scalar context'); | |
195 | is( | |
196 | colorstrip("\e[2cSome other code\e and stray [0m stuff"), | |
b5b25974 | 197 | "\e[2cSome other code\e and stray [0m stuff", |
ba5532d7 CBW |
198 | 'colorstrip does not remove non-color stuff' |
199 | ); | |
b5b25974 | 200 | |
cdab9eb9 | 201 | # Test colorvalid. |
ba5532d7 CBW |
202 | ok( |
203 | colorvalid('blue bold dark', 'blink on_green'), | |
204 | 'colorvalid returns true for valid attributes' | |
205 | ); | |
206 | ok(!colorvalid('green orange'), '...and false for invalid attributes'); | |
207 | ||
208 | # Test error handling in color. | |
209 | my $output = eval { color('chartreuse') }; | |
210 | is($output, undef, 'color on unknown color name fails'); | |
211 | like( | |
212 | $@, | |
213 | qr{ \A Invalid [ ] attribute [ ] name [ ] chartreuse [ ] at [ ] }xms, | |
214 | '...with the right error' | |
215 | ); | |
216 | ||
217 | # Test error handling in colored. | |
218 | $output = eval { colored('Stuff', 'chartreuse') }; | |
219 | is($output, undef, 'colored on unknown color name fails'); | |
220 | like( | |
221 | $@, | |
222 | qr{ \A Invalid [ ] attribute [ ] name [ ] chartreuse [ ] at [ ] }xms, | |
223 | '...with the right error' | |
224 | ); | |
225 | ||
226 | # Test error handling in uncolor. | |
b5b25974 | 227 | $output = eval { uncolor "\e[28m" }; |
ba5532d7 CBW |
228 | is($output, undef, 'uncolor on unknown color code fails'); |
229 | like( | |
230 | $@, | |
231 | qr{ \A No [ ] name [ ] for [ ] escape [ ] sequence [ ] 28 [ ] at [ ] }xms, | |
232 | '...with the right error' | |
233 | ); | |
b5b25974 | 234 | $output = eval { uncolor "\e[foom" }; |
ba5532d7 CBW |
235 | is($output, undef, 'uncolor on bad escape sequence fails'); |
236 | like( | |
237 | $@, | |
238 | qr{ \A Bad [ ] escape [ ] sequence [ ] foo [ ] at [ ] }xms, | |
239 | '...with the right error' | |
240 | ); | |
b5b25974 RGS |
241 | |
242 | # Test error reporting when calling unrecognized Term::ANSIColor subs that go | |
243 | # through AUTOLOAD. | |
ba5532d7 CBW |
244 | ok(!eval { Term::ANSIColor::RSET() }, 'Running invalid constant'); |
245 | like( | |
246 | $@, | |
247 | qr{ \A undefined [ ] subroutine [ ] \&Term::ANSIColor::RSET [ ] called | |
248 | [ ] at [ ] }xms, | |
249 | 'Correct error from an attribute that is not defined' | |
250 | ); | |
251 | ok(!eval { Term::ANSIColor::reset() }, 'Running invalid sub'); | |
252 | like( | |
253 | $@, | |
254 | qr{ \A undefined [ ] subroutine [ ] \&Term::ANSIColor::reset [ ] called | |
255 | [ ] at [ ] }xms, | |
256 | 'Correct error from a lowercase attribute' | |
257 | ); | |
00196a0f CBW |
258 | |
259 | # Ensure that we still get proper error reporting for unknown constants when | |
260 | # when colors are disabled. | |
ba5532d7 CBW |
261 | local $ENV{ANSI_COLORS_DISABLED} = 1; |
262 | eval { Term::ANSIColor::RSET() }; | |
263 | like( | |
264 | $@, | |
265 | qr{ \A undefined [ ] subroutine [ ] \&Term::ANSIColor::RSET [ ] called | |
266 | [ ] at [ ] }xms, | |
267 | 'Correct error from undefined attribute with disabled colors' | |
268 | ); | |
269 | delete $ENV{ANSI_COLORS_DISABLED}; | |
270 | ||
271 | # These are somewhat redundant, but they ensure we test all the branches in | |
272 | # our generated constant subs so that we can use Test::Strict to check test | |
273 | # suite coverage. | |
274 | is((BOLD 't'), "\e[1mt", 'Basic constant works for BOLD'); | |
275 | is((BLUE 't'), "\e[34mt", '...and for BLUE'); | |
276 | is((GREEN 't'), "\e[32mt", '...and for GREEN'); | |
277 | is((DARK 't'), "\e[2mt", '...and for DARK'); | |
278 | is((FAINT 't'), "\e[2mt", '...and for FAINT'); | |
279 | is((BRIGHT_RED 't'), "\e[91mt", '...and for BRIGHT_RED'); | |
280 | is((ON_BRIGHT_RED 't'), "\e[101mt", '...and for ON_BRIGHT_RED'); | |
281 | is((ITALIC 't'), "\e[3mt", '...and for ITALIC'); | |
282 | is((RED 't'), "\e[31mt", '...and for RED'); | |
283 | is((ON_GREEN 't'), "\e[42mt", '...and for ON_GREEN'); | |
284 | is((ON_BLUE 't'), "\e[44mt", '...and for ON_BLUE'); | |
285 | is((RESET 't'), "\e[0mt", '...and for RESET'); | |
286 | ||
287 | # Do the same for disabled colors. | |
288 | local $ENV{ANSI_COLORS_DISABLED} = 1; | |
289 | is(BOLD, q{}, 'ANSI_COLORS_DISABLED works for BOLD'); | |
290 | is(BLUE, q{}, '...and for BLUE'); | |
291 | is(GREEN, q{}, '...and for GREEN'); | |
292 | is(DARK, q{}, '...and for DARK'); | |
293 | is(FAINT, q{}, '...and for FAINT'); | |
294 | is(BRIGHT_RED, q{}, '...and for BRIGHT_RED'); | |
295 | is(ON_BRIGHT_RED, q{}, '...and for ON_BRIGHT_RED'); | |
296 | is(ITALIC, q{}, '...and for ITALIC'); | |
297 | is(RED, q{}, '...and for RED'); | |
298 | is(ON_GREEN, q{}, '...and for ON_GREEN'); | |
299 | is(ON_BLUE, q{}, '...and for ON_BLUE'); | |
300 | is(RESET, q{}, '...and for RESET'); | |
00196a0f | 301 | delete $ENV{ANSI_COLORS_DISABLED}; |
ba5532d7 CBW |
302 | |
303 | # Do the same for AUTORESET. | |
304 | $Term::ANSIColor::AUTORESET = 1; | |
305 | is((BOLD 't'), "\e[1mt\e[0m", 'AUTORESET works for BOLD'); | |
306 | is((BLUE 't'), "\e[34mt\e[0m", '...and for BLUE'); | |
307 | is((GREEN 't'), "\e[32mt\e[0m", '...and for GREEN'); | |
308 | is((DARK 't'), "\e[2mt\e[0m", '...and for DARK'); | |
309 | is((FAINT 't'), "\e[2mt\e[0m", '...and for FAINT'); | |
310 | is((BRIGHT_RED 't'), "\e[91mt\e[0m", '...and for BRIGHT_RED'); | |
311 | is((ON_BRIGHT_RED 't'), "\e[101mt\e[0m", '...and for ON_BRIGHT_RED'); | |
312 | is((ITALIC 't'), "\e[3mt\e[0m", '...and for ITALIC'); | |
313 | is((RED 't'), "\e[31mt\e[0m", '...and for RED'); | |
314 | is((ON_GREEN 't'), "\e[42mt\e[0m", '...and for ON_GREEN'); | |
315 | is((ON_BLUE 't'), "\e[44mt\e[0m", '...and for ON_BLUE'); | |
316 | is((RESET 't'), "\e[0mt\e[0m", '...and for RESET'); | |
317 | is((BOLD), "\e[1m", 'AUTORESET without text for BOLD'); | |
318 | is((BLUE), "\e[34m", '...and for BLUE'); | |
319 | is((GREEN), "\e[32m", '...and for GREEN'); | |
320 | is((DARK), "\e[2m", '...and for DARK'); | |
321 | is((FAINT), "\e[2m", '...and for FAINT'); | |
322 | is((BRIGHT_RED), "\e[91m", '...and for BRIGHT_RED'); | |
323 | is((ON_BRIGHT_RED), "\e[101m", '...and for ON_BRIGHT_RED'); | |
324 | is((ITALIC), "\e[3m", '...and for ITALIC'); | |
325 | is((RED), "\e[31m", '...and for RED'); | |
326 | is((ON_GREEN), "\e[42m", '...and for ON_GREEN'); | |
327 | is((ON_BLUE), "\e[44m", '...and for ON_BLUE'); | |
328 | is((RESET), "\e[0m", '...and for RESET'); | |
329 | $Term::ANSIColor::AUTORESET = 0; | |
330 | ||
331 | # Do the same for AUTOLOCAL. | |
332 | $Term::ANSIColor::AUTOLOCAL = 1; | |
333 | is((BOLD 't'), "\e[1mt\e[0m", 'AUTOLOCAL works for BOLD'); | |
334 | is((BLUE 't'), "\e[34mt\e[0m", '...and for BLUE'); | |
335 | is((GREEN 't'), "\e[32mt\e[0m", '...and for GREEN'); | |
336 | is((DARK 't'), "\e[2mt\e[0m", '...and for DARK'); | |
337 | is((FAINT 't'), "\e[2mt\e[0m", '...and for FAINT'); | |
338 | is((BRIGHT_RED 't'), "\e[91mt\e[0m", '...and for BRIGHT_RED'); | |
339 | is((ON_BRIGHT_RED 't'), "\e[101mt\e[0m", '...and for ON_BRIGHT_RED'); | |
340 | is((ITALIC 't'), "\e[3mt\e[0m", '...and for ITALIC'); | |
341 | is((RED 't'), "\e[31mt\e[0m", '...and for RED'); | |
342 | is((ON_GREEN 't'), "\e[42mt\e[0m", '...and for ON_GREEN'); | |
343 | is((ON_BLUE 't'), "\e[44mt\e[0m", '...and for ON_BLUE'); | |
344 | is((RESET 't'), "\e[0mt\e[0m", '...and for RESET'); | |
345 | is((BOLD), "\e[1m", 'AUTOLOCAL without text for BOLD'); | |
346 | is((BLUE), "\e[34m", '...and for BLUE'); | |
347 | is((GREEN), "\e[32m", '...and for GREEN'); | |
348 | is((DARK), "\e[2m", '...and for DARK'); | |
349 | is((FAINT), "\e[2m", '...and for FAINT'); | |
350 | is((BRIGHT_RED), "\e[91m", '...and for BRIGHT_RED'); | |
351 | is((ON_BRIGHT_RED), "\e[101m", '...and for ON_BRIGHT_RED'); | |
352 | is((ITALIC), "\e[3m", '...and for ITALIC'); | |
353 | is((RED), "\e[31m", '...and for RED'); | |
354 | is((ON_GREEN), "\e[42m", '...and for ON_GREEN'); | |
355 | is((ON_BLUE), "\e[44m", '...and for ON_BLUE'); | |
356 | is((RESET), "\e[0m", '...and for RESET'); | |
357 | $Term::ANSIColor::AUTOLOCAL = 0; | |
358 | ||
359 | # Force an internal error inside the AUTOLOAD stub by creating an attribute | |
360 | # that will generate a syntax error. This is just for coverage purposes. | |
361 | # Disable warnings since our syntax error will spew otherwise. | |
362 | local $SIG{__WARN__} = sub { }; | |
363 | $Term::ANSIColor::ATTRIBUTES{yellow} = q{'ERROR'}; | |
364 | ok(!eval { YELLOW 't' }, 'Caught internal AUTOLOAD error'); | |
365 | like( | |
366 | $@, | |
367 | qr{ \A failed [ ] to [ ] generate [ ] constant [ ] YELLOW: [ ] }xms, | |
368 | '...with correct error message' | |
369 | ); |