Skip to content

Commit 8dc29e8

Browse files
committed
fixed typo in space shape
1 parent 7694bdf commit 8dc29e8

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

lib/Graphics/Toolkit/Color/Space/Format.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sub new {
1616
my $number_form = '-?(?:\d+|\d+\.\d+|.\d+)';
1717
my $count = $basis->count;
1818
$value_form = [($number_form) x $count] unless defined $value_form;
19-
$value_form = [($value_form) x $count] unless ref $suffix;
19+
$value_form = [($value_form) x $count] unless ref $value_form;
2020
$value_form = [ map {(defined $_ and $_) ? $_ : $number_form } @$value_form]; # fill missing defs with default
2121
return 'need an ARRAY as definition of value format' unless ref $value_form eq 'ARRAY';
2222
return 'definition value format has to have same length as basis (number of axis)' unless @$value_form == $count;

t/03_space_shape.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use v5.12;
44
use warnings;
5-
use Test::More tests => 116;
5+
use Test::More tests => 118;
66

77
BEGIN { unshift @INC, 'lib', '../lib'}
88
my $module = 'Graphics::Toolkit::Color::Space::Shape';
@@ -132,6 +132,8 @@ is( $tr->[1], 1.1, 'rounded in range value to set precision');
132132
is( $tr->[2], 2.54, 'in range value is kept');
133133

134134

135+
is( ref $shape->in_range(1,2,3), '', 'need array ref, not list');
136+
is( ref $shape->in_range({}), '', 'need array, not other ref');
135137
is( ref $shape->in_range([1,2,3]), 'ARRAY', 'all values in range');
136138
is( ref $shape->in_range([1,2]), '', "not enough values");
137139
is( ref $shape->in_range([1,2,3,4]), '', "too many values");

t/04_space_format.t

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use v5.12;
44
use warnings;
5-
use Test::More tests => 101;
5+
use Test::More tests => 107;
66

77
BEGIN { unshift @INC, 'lib', '../lib'}
88
my $module = 'Graphics::Toolkit::Color::Space::Format';
@@ -20,6 +20,8 @@ is( ref $obj, $module, 'one constructor argument is enough');
2020
my $pobj = Graphics::Toolkit::Color::Space::Format->new( $basis, '%' );
2121
is( ref $pobj, $module, 'used second argument: suffix');
2222

23+
my $vobj = Graphics::Toolkit::Color::Space::Format->new( $basis, '%', '\d{2}' );
24+
is( ref $pobj, $module, 'used third argument argument: value format');
2325

2426
my ($vals, $name) = $obj->deformat('abg:0,2.2,-3');
2527
is( ref $vals, 'ARRAY', 'could deformat values');
@@ -41,6 +43,12 @@ is( $name, 'named_string', 'found right format name');
4143
is( ref $vals, 'ARRAY', 'ignored inserted spaces in named string');
4244
is( $name, 'named_string', 'recognized named string format');
4345

46+
($vals, $name) = $vobj->deformat(' abg: 1 %, 2 % , 3% ');
47+
is( ref $vals, '', 'values need to have two digits with custom value format');
48+
($vals, $name) = $vobj->deformat(' abg: 11 %, 22 % , 33% ');
49+
is( ref $vals, 'ARRAY', 'ignored inserted spaces in named string with custom value format');
50+
is( $name, 'named_string', 'recognized named string format with custom value format');
51+
4452

4553
($vals, $name) = $pobj->deformat(' abg( 1 %, 2 % , 3% ) ');
4654
is( ref $vals, 'ARRAY', 'ignored inserted spaces in css string');
@@ -106,6 +114,10 @@ is( $name, 'hash', 'recognized hash format with full names');
106114
is( $name, 'hash', 'recognized hash even when left suffixes');
107115
($vals, $name) = $pobj->deformat( {ALPHA =>'1 %', BETA =>'2% ', GAMMA=>' 3%'} );
108116
is( $name, 'hash', 'recognized hash with suffixes');
117+
($vals, $name) = $vobj->deformat( {ALPHA =>'1 %', BETA =>'2% ', GAMMA=>' 3%'} );
118+
is( $name, undef, 'values needed 2 digits in custom value format');
119+
($vals, $name) = $vobj->deformat( {ALPHA =>'21 %', BETA =>'92% ', GAMMA=>' 13%'} );
120+
is( $name, 'hash', 'recognized hash with suffixes and custom value format');
109121

110122

111123

0 commit comments

Comments
 (0)