Allow leading '#' for hex colors
parent
942c87147b
commit
67460e170d
|
@ -18,7 +18,7 @@ triggers any => 'color', 'colour';
|
|||
triggers start => 'mix';
|
||||
|
||||
my $scolor = 'colou?r';
|
||||
my $color_re = '\p{XDigit}{6}';
|
||||
my $color_re = '#?\p{XDigit}{6}';
|
||||
|
||||
#############
|
||||
# Helpers #
|
||||
|
|
12
t/RgbColor.t
12
t/RgbColor.t
|
@ -68,6 +68,11 @@ sub build_test { test_zci(build_structured_answer(@_)) }
|
|||
# Test Cases #
|
||||
################
|
||||
|
||||
my $tc_mix_white_black = build_test('mix',
|
||||
input_colors => ['#000000', '#ffffff'],
|
||||
result_color => '#7f7f7f',
|
||||
);
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::RgbColor )],
|
||||
# Random colors
|
||||
|
@ -76,10 +81,9 @@ ddg_goodie_test(
|
|||
# Using 'colour'
|
||||
'random colour' => build_test('random'),
|
||||
# Mixing colors
|
||||
'mix 000000 ffffff' => build_test('mix',
|
||||
input_colors => ['#000000', '#ffffff'],
|
||||
result_color => '#7f7f7f',
|
||||
),
|
||||
'mix 000000 ffffff' => $tc_mix_white_black,
|
||||
# # With leading '#'
|
||||
'mix #000000 #ffffff' => $tc_mix_white_black,
|
||||
# Invalid queries
|
||||
'color' => undef,
|
||||
'color ffffff' => undef,
|
||||
|
|
Loading…
Reference in New Issue