diff options
author | Manoj Srivastava <srivasta@debian.org> | 2005-04-29 21:23:32 +0000 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2005-04-29 21:23:32 +0000 |
commit | 4a8e1f8fb3af552e815a06f476554884e91ea9a8 (patch) | |
tree | 9243d57c5e34389aded7eec5a6e039f3f229c93e | |
parent | 4a54151d3b9206ee00e0108e95193565816e4b7b (diff) |
Imported Graphics-ColorNames-1.06
Imported Graphics-ColorNames-1.06
into srivasta@debian.org--2003-primary/libgraphics-colornames-perl--upstream--0.0
git-archimport-id: srivasta@debian.org--2003-primary/libgraphics-colornames-perl--upstream--0.0--patch-2
-rw-r--r-- | Build.PL | 51 | ||||
-rw-r--r-- | Changes | 9 | ||||
-rw-r--r-- | MANIFEST | 4 | ||||
-rw-r--r-- | META.yml | 13 | ||||
-rw-r--r-- | Makefile.PL | 1 | ||||
-rw-r--r-- | README | 143 | ||||
-rw-r--r-- | SIGNATURE | 48 | ||||
-rw-r--r-- | lib/Graphics/ColorNames.pm | 21 | ||||
-rw-r--r-- | lib/Graphics/ColourNames.pm | 130 | ||||
-rw-r--r-- | t/00-Prereqs.t | 8 | ||||
-rw-r--r-- | t/00-pod-coverage.t | 15 | ||||
-rw-r--r-- | t/00-pod.t | 12 | ||||
-rw-r--r-- | t/01-ColorNames.t | 158 | ||||
-rw-r--r-- | t/01-ColourNames.t | 157 | ||||
-rw-r--r-- | t/02-X.t | 42 | ||||
-rw-r--r-- | t/03-HTML.t | 49 | ||||
-rw-r--r-- | t/04-Windows.t | 42 | ||||
-rw-r--r-- | t/05-Netscape.t | 57 | ||||
-rw-r--r-- | t/06-obj.t | 94 | ||||
-rw-r--r-- | t/07-file.t | 50 | ||||
-rw-r--r-- | t/08-filehandle.t | 58 |
21 files changed, 632 insertions, 530 deletions
@@ -1,24 +1,27 @@ -use Module::Build; - -my $build = Module::Build->new - ( - module_name => 'Graphics::ColorNames', - license => 'perl', - requires => { - 'perl' => '5.6.0', - 'base' => 0, - 'Carp' => 0, - 'IO::File' => 0, - 'Module::Load' => 0.10, - }, - recommends => { - }, - build_requires => { - 'Test::More' => 0, - 'Test' => 0, - }, - create_makefile_pl => 'traditional', - dist_author => 'Robert Rothenberg <rrwo at cpan.org>', -); - -$build->create_build_script; +use Module::Build;
+
+my $build = Module::Build->new
+ (
+ module_name => 'Graphics::ColorNames',
+ license => 'perl',
+ requires => {
+ 'perl' => '5.6.0',
+ 'base' => 0,
+ 'Carp' => 0,
+ 'IO::File' => 0,
+ 'Module::Load' => 0.10,
+ },
+ recommends => {
+ 'Pod::Coverage' => 0,
+ 'Test::Pod' => 1.00,
+ 'Test::Prereq' => 0,
+ },
+ build_requires => {
+ 'Test::More' => 0,
+ },
+ create_makefile_pl => 'traditional',
+ dist_author => 'Robert Rothenberg <rrwo at cpan.org>',
+ sign => 1,
+);
+
+$build->create_build_script;
@@ -1,5 +1,14 @@ Revision history for Perl extension Graphics::ColorNames.
+1.06 Tue Mar 29 2005
+ - cleaned up tests
+ - added DSLIP information to POD
+ - added Test::Pod tests
+ - added Pod::Coverage tests
+ - minor documentation changes
+ - uses Test::Prereq to test distro prereqs
+ - added SIGNATURE to distribution
+
1.05 Fri Sep 3 2004
- correction to Graphics::ColourNames
- correction to README
@@ -4,6 +4,9 @@ Makefile.PL MANIFEST
META.yml
README
+t/00-Prereqs.t
+t/00-pod-coverage.t
+t/00-pod.t
t/01-ColorNames.t
t/01-ColourNames.t
t/02-X.t
@@ -21,3 +24,4 @@ lib/Graphics/ColorNames/Windows.pm lib/Graphics/ColorNames/X.pm
lib/Graphics/ColourNames.pm
+SIGNATURE Added here by Module::Build
@@ -1,6 +1,6 @@ --- #YAML:1.0
name: Graphics-ColorNames
-version: 1.05
+version: 1.06
author:
- Robert Rothenberg <rrwo at cpan.org>
abstract: defines RGB values for common color names
@@ -11,13 +11,16 @@ requires: Module::Load: 0.1
base: 0
perl: 5.6.0
+recommends:
+ Pod::Coverage: 0
+ Test::Pod: 1
+ Test::Prereq: 0
build_requires:
- Test: 0
Test::More: 0
provides:
Graphics::ColorNames:
file: lib/Graphics/ColorNames.pm
- version: 1.05
+ version: 1.06
Graphics::ColorNames::HTML:
file: lib/Graphics/ColorNames/HTML.pm
version: 1.11
@@ -32,5 +35,5 @@ provides: version: 1.06
Graphics::ColourNames:
file: lib/Graphics/ColourNames.pm
- version: 1.05
-generated_by: Module::Build version 0.25_02
+ version: 1.06
+generated_by: Module::Build version 0.2607
diff --git a/Makefile.PL b/Makefile.PL index 3fb8947..90699e1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -8,7 +8,6 @@ WriteMakefile 'Carp' => '0',
'IO::File' => '0',
'Module::Load' => '0.1',
- 'Test' => '0',
'Test::More' => '0',
'base' => '0'
},
@@ -1,71 +1,72 @@ -NAME - Graphics::ColorNames - defines RGB values for common color names - -REQUIREMENTS - `Graphics::ColorNames' should work on Perl 5.6.0. - - It requires the following non-standard modules: - - Module::Load - - Installation - - Installation is pretty standard: - - perl Makefile.PL - make - make test - make install - - (On Windows platforms you should use nmake instead.) - - Using Build.PL (if you have Module::Build installed): - - perl Build.PL - perl Build - perl Build test - perl Build install - -SYNOPSIS - use Graphics::ColorNames qw( hex2tuple tuple2hex ); - - tie %NameTable, 'Graphics::ColorNames', 'X'; - - my $rgbhex1 = $NameTable{'green'}; # returns '00ff00' - my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00' - my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0) - - my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc' - my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc' - -DESCRIPTION - This module defines RGB values for common color names. The intention is - to (1) provide a common module that authors can use with other modules - to specify colors; and (2) free module authors from having to "re-invent - the wheel" whenever they decide to give the users the option of - specifying a color by name rather than RGB value. - - A more detailed description with documentation can be found in the - module's POD. - -HISTORY - Revision history since v1.03: - - 1.05 Fri Sep 3 2004 - - correction to Graphics::ColourNames - - correction to README - - 1.04 Fri Sep 3 2004 - - updates to POD - - a filehandle for a rgb.txt file can be specified - - A more detailed revision history is available in the Changes file. - -AUTHOR - Robert Rothenberg <rrwo at cpan.org> - -LICENSE - Copyright (c) 2001-2004 Robert Rothenberg. All rights - reserved. This program is free software; you can redistribute it - and/or modify it under the same terms as Perl itself. - +NAME
+ Graphics::ColorNames - defines RGB values for common color names
+
+REQUIREMENTS
+ `Graphics::ColorNames' should work on Perl 5.6.0.
+
+ It requires the following non-standard modules:
+
+ Module::Load
+
+ Installation
+
+ Installation is pretty standard:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+ (On Windows platforms you should use nmake instead.)
+
+ Using Build.PL (if you have Module::Build installed):
+
+ perl Build.PL
+ perl Build
+ perl Build test
+ perl Build install
+
+SYNOPSIS
+ use Graphics::ColorNames qw( hex2tuple tuple2hex );
+
+ tie %NameTable, 'Graphics::ColorNames', 'X';
+
+ my $rgbhex1 = $NameTable{'green'}; # returns '00ff00'
+ my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00'
+ my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0)
+
+ my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
+ my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc'
+
+DESCRIPTION
+ This module defines RGB values for common color names. The intention is
+ to (1) provide a common module that authors can use with other modules
+ to specify colors; and (2) free module authors from having to "re-invent
+ the wheel" whenever they decide to give the users the option of
+ specifying a color by name rather than RGB value.
+
+ A more detailed description with documentation can be found in the
+ module's POD.
+
+HISTORY
+ Revision history since the last release:
+
+ 1.06 Tue Mar 29 2005
+ - cleaned up tests
+ - added DSLIP information to POD
+ - added Test::Pod tests
+ - added Pod::Coverage tests
+ - minor documentation changes
+ - uses Test::Prereq to test distro prereqs
+ - added SIGNATURE to distribution
+
+ A more detailed revision history is available in the Changes file.
+
+AUTHOR
+ Robert Rothenberg <rrwo at cpan.org>
+
+LICENSE
+ Copyright (c) 2001-2005 Robert Rothenberg. All rights
+ reserved. This program is free software; you can redistribute it
+ and/or modify it under the same terms as Perl itself.
+
diff --git a/SIGNATURE b/SIGNATURE new file mode 100644 index 0000000..e79ce2c --- /dev/null +++ b/SIGNATURE @@ -0,0 +1,48 @@ +This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.44.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+ % cpansign -v
+
+It will check each file's integrity, as well as the signature's
+validity. If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 09d8e07ed2906851bc648c38764d954ae65ae9c0 Build.PL
+SHA1 f914d5d44538dff1eacc5b4be581387bd786e4df Changes
+SHA1 b5523653c65c2b15b0c10c7c3821b76c26db901e MANIFEST
+SHA1 22f4ac1e4f24793e3a54f575a623bf6dd4eb7a98 META.yml
+SHA1 0626b548af56d29d44faa6d7509e3ead5b7aa343 Makefile.PL
+SHA1 85eaead1e33535c579304ef2116aa9722c9b39f0 README
+SHA1 94fe6e319f6158139af6a7b4ba4a4cea3d697d14 lib/Graphics/ColorNames.pm
+SHA1 4db6a372a70f1a4b90a46e153330b7a570757023 lib/Graphics/ColorNames/HTML.pm
+SHA1 ea38a6c660621a7c57cb9f31bb44737cdfe3d7b2 lib/Graphics/ColorNames/Netscape.pm
+SHA1 161469f8bcfb14ef693bfd315c0e41b3721bd16b lib/Graphics/ColorNames/Windows.pm
+SHA1 dfdd478039e0f5d8f6351d8a1d90c53e16343de1 lib/Graphics/ColorNames/X.pm
+SHA1 d28b85622781d77fe5f23c4c2f3dfea82939ade5 lib/Graphics/ColourNames.pm
+SHA1 c7d63443ba312c659cf441d89231a065d9e6d716 t/00-Prereqs.t
+SHA1 bef0f210e3cd888a0fbc10c40ee90419b8d079e3 t/00-pod-coverage.t
+SHA1 a7be5b4aad4ce3f7a59d6e3cd654ee6c6e642344 t/00-pod.t
+SHA1 414dfe0a0c0cc08f5b1171e0a8d5d29872fedd91 t/01-ColorNames.t
+SHA1 80cd23ecd10a62e678d998fa0f884188c405edf1 t/01-ColourNames.t
+SHA1 e02321c84d2fc9cb23d5ef546e79659209cddbb0 t/02-X.t
+SHA1 375ff88426e0c83fc93c79b5b328c613d9824add t/03-HTML.t
+SHA1 0a7f6ff67e286cd5a7e6ad84986675fb8e346149 t/04-Windows.t
+SHA1 461c697b85a232a3237737abe4fd85a4ea70a586 t/05-Netscape.t
+SHA1 d510ca893737063097fd25242d8b3a940755c7bd t/06-obj.t
+SHA1 8d01b6fd40a4f3b5a084fef41d0212b70de36983 t/07-file.t
+SHA1 c1d92dcde46607a45b3b8aceed1aa4201340409b t/08-filehandle.t
+SHA1 d3e7e6d18177d7885cbd06d3f37b7a89f539c68d t/rgb.txt
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.2.5 (MingW32)
+
+iD8DBQFCSd8RV485gMKcmRARArJgAJsGdC2oFLJSIOEEyov9S/DppEgApwCgjJlk
+BfnMi//CPmr0GmN+xJ1UUxo=
+=x/+X
+-----END PGP SIGNATURE-----
diff --git a/lib/Graphics/ColorNames.pm b/lib/Graphics/ColorNames.pm index 368c355..ed44b2f 100644 --- a/lib/Graphics/ColorNames.pm +++ b/lib/Graphics/ColorNames.pm @@ -11,7 +11,7 @@ use Module::Load; our @ISA = qw( Exporter );
-our $VERSION = '1.05';
+our $VERSION = '1.06';
# $VERSION = eval $VERSION;
our @EXPORT = qw( );
@@ -67,6 +67,8 @@ sub _load_scheme my $self = shift;
my $scheme = shift;
+ # Should this be switched to use Module::Pluggable? Hm....
+
my $module = join('::', __PACKAGE__, $scheme);
eval {
load $module;
@@ -385,7 +387,7 @@ be used: =head2 Color Schemes
-Currently four schemes are available:
+The following schemes are available by default:
=over
@@ -405,6 +407,9 @@ are also used with CSS and SVG. they were once usable in Netscape or were arbitrary names for RGB values--
many of these names are not recognized by later versions of Netscape).
+This scheme may be deprecated in future versions, but available as a
+separate module.
+
=item Windows
16 commom color names used with Microsoft Windows and related products.
@@ -472,6 +477,16 @@ F<rgb.txt> file. L<Graphics::ColorObject> can convert between RGB and other color space
types.
+=head1 DSLIP
+
+ R - Released
+ d - Developer
+ p - Perl-only
+ h - Hybrid interface
+ p - Standard Perl
+
+See L<http://cpan.uwinnipeg.ca/htdocs/faqs/dslip.html>
+
=head1 AUTHOR
Robert Rothenberg <rrwo at cpan.org>
@@ -501,7 +516,7 @@ this module. =head1 LICENSE
-Copyright (c) 2001-2004 Robert Rothenberg. All rights reserved.
+Copyright (c) 2001-2005 Robert Rothenberg. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
diff --git a/lib/Graphics/ColourNames.pm b/lib/Graphics/ColourNames.pm index 6cbedbb..df5b43b 100644 --- a/lib/Graphics/ColourNames.pm +++ b/lib/Graphics/ColourNames.pm @@ -1,65 +1,65 @@ -package Graphics::ColourNames; - -require 5.006; - -use strict; -use warnings; - -require Graphics::ColorNames; - -use base 'Graphics::ColorNames'; - -our $VERSION = '1.05'; - -our @EXPORT = qw( ); -our @EXPORT_OK = qw( hex2tuple tuple2hex ); - -sub hex2tuple { - goto &Graphics::ColorNames::hex2tuple; -} - -sub tuple2hex { - goto &Graphics::ColorNames::tuple2hex; -} - -1; - -__END__ - -=head1 NAME - -Graphics::ColourNames - alias for Graphics::ColorNames - -=head1 SYNOPSIS - - use Graphics::ColourNames qw( hex2tuple tuple2hex ); - - tie %NameTable, 'Graphics::ColourNames', 'X'; - - my $rgbhex1 = $NameTable{'green'}; # returns '00ff00' - my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00' - my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0) - - my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc' - my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc' - -=head1 DESCRIPTION - -This module is an alias for L<Graphics::ColorNames>, using the British -style of spelling. - -It does not alter the spelling of individual colour names in colour -schemas. - -=head1 AUTHOR - -Robert Rothenberg <rrwo at cpan.org> - -=head1 LICENSE - -Copyright (c) 2004 Robert Rothenberg. All rights reserved. -This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -=cut - +package Graphics::ColourNames;
+
+require 5.006;
+
+use strict;
+use warnings;
+
+require Graphics::ColorNames;
+
+use base 'Graphics::ColorNames';
+
+our $VERSION = '1.06';
+
+our @EXPORT = qw( );
+our @EXPORT_OK = qw( hex2tuple tuple2hex );
+
+sub hex2tuple {
+ goto &Graphics::ColorNames::hex2tuple;
+}
+
+sub tuple2hex {
+ goto &Graphics::ColorNames::tuple2hex;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Graphics::ColourNames - alias for Graphics::ColorNames
+
+=head1 SYNOPSIS
+
+ use Graphics::ColourNames qw( hex2tuple tuple2hex );
+
+ tie %NameTable, 'Graphics::ColourNames', 'X';
+
+ my $rgbhex1 = $NameTable{'green'}; # returns '00ff00'
+ my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00'
+ my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0)
+
+ my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
+ my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc'
+
+=head1 DESCRIPTION
+
+This module is an alias for L<Graphics::ColorNames>, using the British
+style of spelling.
+
+It does not alter the spelling of individual colour names in colour
+schemas.
+
+=head1 AUTHOR
+
+Robert Rothenberg <rrwo at cpan.org>
+
+=head1 LICENSE
+
+Copyright (c) 2004-2005 Robert Rothenberg. All rights reserved.
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut
+
diff --git a/t/00-Prereqs.t b/t/00-Prereqs.t new file mode 100644 index 0000000..bdd8324 --- /dev/null +++ b/t/00-Prereqs.t @@ -0,0 +1,8 @@ +#!/usr/bin/perl
+
+use strict;
+use Test::More;
+
+eval "use Test::Prereq";
+plan skip_all => "Test::Prereq required to test dependencies" if $@;
+prereq_ok();
diff --git a/t/00-pod-coverage.t b/t/00-pod-coverage.t new file mode 100644 index 0000000..47cf647 --- /dev/null +++ b/t/00-pod-coverage.t @@ -0,0 +1,15 @@ +#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 6;
+
+eval "use Pod::Coverage";
+
+plan skip_all => "Pod::Coverage required" if $@;
+
+ok( Pod::Coverage->new( package => 'Graphics::ColorNames' ) );
+ok( Pod::Coverage->new( package => 'Graphics::ColourNames' ) );
+ok( Pod::Coverage->new( package => 'Graphics::ColorNames::X' ) );
+ok( Pod::Coverage->new( package => 'Graphics::ColorNames::HTML' ) );
+ok( Pod::Coverage->new( package => 'Graphics::ColorNames::Windows' ) );
+ok( Pod::Coverage->new( package => 'Graphics::ColorNames::Netscape' ) );
diff --git a/t/00-pod.t b/t/00-pod.t new file mode 100644 index 0000000..a2c0593 --- /dev/null +++ b/t/00-pod.t @@ -0,0 +1,12 @@ +#!/usr/bin/perl
+
+use strict;
+use Test::More;
+
+eval "use Test::Pod 1.00";
+
+plan skip_all => "Test::Pod 1.00 required" if $@;
+
+my @poddirs = qw( blib );
+
+all_pod_files_ok( all_pod_files( @poddirs ) );
diff --git a/t/01-ColorNames.t b/t/01-ColorNames.t index 36062d3..dfa4f7c 100644 --- a/t/01-ColorNames.t +++ b/t/01-ColorNames.t @@ -1,80 +1,78 @@ -use Test; - -BEGIN { plan tests => 44, todo => [ ] } - -use strict; -use Carp; - -use Graphics::ColorNames 0.30, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames'; -ok(1); - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); - -$count = 0; -foreach my $name (keys %colors) - { - $count++, if ($colors{lc($name)} eq $colors{uc($name)}); - } -ok($count, keys %colors); - - -$count = 0; -foreach my $name (keys %colors) - { - $count++, if (exists($colors{$name})) - } -ok($count, keys %colors); - -# Test CLEAR, DELETE and STORE as returning errors - -eval { undef %colors }; -ok(defined($!)); - -eval { %colors = (); }; -ok(defined($!)); - -eval { $colors{MyCustomColor} = 'FFFFFF'; }; -ok(defined($!)); - -eval { delete($colors{MyCustomColor}); }; -ok(defined($!)); - -# Test RGB values being passed through - -foreach my $rgb (qw( - 000000 000001 000010 000100 001000 010000 100000 - 111111 123abc abc123 123ABC ABC123 abcdef ABCDEF - )) { - ok($colors{ "\x23" . $rgb } eq $rgb); - ok($colors{ $rgb } eq $rgb); -} - -# Test using multiple schemes - -tie my %colors2, 'Graphics::ColorNames', qw( X Netscape ); - -ok(!exists $colors{Silver}); # Silver doesn't exist in X -ok(defined $colors2{Silver}); # It does in Netscape - -# Test precedence - -tie my %colors3, 'Graphics::ColorNames', qw( Netscape X ); - -ok($colors{Brown}, 'a52a2a'); # Brown in X -ok($colors2{Brown}, 'a52a2a'); # Brown in X (don't try Netscape) -ok($colors3{Brown}, 'a62a2a'); # Brown in Netscape (don't try X) - -# Test handling of non-existent color names - -ok(!defined $colors{NonExistentColorName}); -ok(!exists $colors{NonExistentColorName}); - +#!/usr/bin/perl
+
+use strict;
+
+use Test::More tests => 44;
+
+use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames';
+ok(tied %colors);
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
+
+$count = 0;
+foreach my $name (keys %colors)
+ {
+ $count++, if ($colors{lc($name)} eq $colors{uc($name)});
+ }
+ok($count == keys %colors);
+
+
+$count = 0;
+foreach my $name (keys %colors)
+ {
+ $count++, if (exists($colors{$name}))
+ }
+ok($count == keys %colors);
+
+# Test CLEAR, DELETE and STORE as returning errors
+
+eval { undef %colors };
+ok(defined($!));
+
+eval { %colors = (); };
+ok(defined($!));
+
+eval { $colors{MyCustomColor} = 'FFFFFF'; };
+ok(defined($!));
+
+eval { delete($colors{MyCustomColor}); };
+ok(defined($!));
+
+# Test RGB values being passed through
+
+foreach my $rgb (qw(
+ 000000 000001 000010 000100 001000 010000 100000
+ 111111 123abc abc123 123ABC ABC123 abcdef ABCDEF
+ )) {
+ ok($colors{ "\x23" . $rgb } eq $rgb);
+ ok($colors{ $rgb } eq $rgb);
+}
+
+# Test using multiple schemes
+
+tie my %colors2, 'Graphics::ColorNames', qw( X Netscape );
+
+ok(!exists $colors{Silver}); # Silver doesn't exist in X
+ok(defined $colors2{Silver}); # It does in Netscape
+
+# Test precedence
+
+tie my %colors3, 'Graphics::ColorNames', qw( Netscape X );
+
+ok($colors{Brown}, 'a52a2a'); # Brown in X
+ok($colors2{Brown}, 'a52a2a'); # Brown in X (don't try Netscape)
+ok($colors3{Brown}, 'a62a2a'); # Brown in Netscape (don't try X)
+
+# Test handling of non-existent color names
+
+ok(!defined $colors{NonExistentColorName});
+ok(!exists $colors{NonExistentColorName});
+
diff --git a/t/01-ColourNames.t b/t/01-ColourNames.t index 256fdf2..bef6b02 100644 --- a/t/01-ColourNames.t +++ b/t/01-ColourNames.t @@ -1,80 +1,77 @@ -use Test; - -BEGIN { plan tests => 44, todo => [ ] } - -use strict; -use Carp; - -use Graphics::ColourNames 0.30, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColourNames'; -ok(1); - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); - -$count = 0; -foreach my $name (keys %colors) - { - $count++, if ($colors{lc($name)} eq $colors{uc($name)}); - } -ok($count, keys %colors); - - -$count = 0; -foreach my $name (keys %colors) - { - $count++, if (exists($colors{$name})) - } -ok($count, keys %colors); - -# Test CLEAR, DELETE and STORE as returning errors - -eval { undef %colors }; -ok(defined($!)); - -eval { %colors = (); }; -ok(defined($!)); - -eval { $colors{MyCustomColour} = 'FFFFFF'; }; -ok(defined($!)); - -eval { delete($colors{MyCustomColour}); }; -ok(defined($!)); - -# Test RGB values being passed through - -foreach my $rgb (qw( - 000000 000001 000010 000100 001000 010000 100000 - 111111 123abc abc123 123ABC ABC123 abcdef ABCDEF - )) { - ok($colors{ "\x23" . $rgb } eq $rgb); - ok($colors{ $rgb } eq $rgb); -} - -# Test using multiple schemes - -tie my %colors2, 'Graphics::ColourNames', qw( X Netscape ); - -ok(!exists $colors{Silver}); # Silver doesn't exist in X -ok(defined $colors2{Silver}); # It does in Netscape - -# Test precedence - -tie my %colors3, 'Graphics::ColourNames', qw( Netscape X ); - -ok($colors{Brown}, 'a52a2a'); # Brown in X -ok($colors2{Brown}, 'a52a2a'); # Brown in X (don't try Netscape) -ok($colors3{Brown}, 'a62a2a'); # Brown in Netscape (don't try X) - -# Test handling of non-existent color names - -ok(!defined $colors{NonExistentColourName}); -ok(!exists $colors{NonExistentColourName}); - +#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 44;
+
+use_ok( 'Graphics::ColourNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColourNames';
+ok(1);
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
+
+$count = 0;
+foreach my $name (keys %colors)
+ {
+ $count++, if ($colors{lc($name)} eq $colors{uc($name)});
+ }
+ok($count == keys %colors);
+
+
+$count = 0;
+foreach my $name (keys %colors)
+ {
+ $count++, if (exists($colors{$name}))
+ }
+ok($count == keys %colors);
+
+# Test CLEAR, DELETE and STORE as returning errors
+
+eval { undef %colors };
+ok(defined($!));
+
+eval { %colors = (); };
+ok(defined($!));
+
+eval { $colors{MyCustomColour} = 'FFFFFF'; };
+ok(defined($!));
+
+eval { delete($colors{MyCustomColour}); };
+ok(defined($!));
+
+# Test RGB values being passed through
+
+foreach my $rgb (qw(
+ 000000 000001 000010 000100 001000 010000 100000
+ 111111 123abc abc123 123ABC ABC123 abcdef ABCDEF
+ )) {
+ ok($colors{ "\x23" . $rgb } eq $rgb);
+ ok($colors{ $rgb } eq $rgb);
+}
+
+# Test using multiple schemes
+
+tie my %colors2, 'Graphics::ColourNames', qw( X Netscape );
+
+ok(!exists $colors{Silver}); # Silver doesn't exist in X
+ok(defined $colors2{Silver}); # It does in Netscape
+
+# Test precedence
+
+tie my %colors3, 'Graphics::ColourNames', qw( Netscape X );
+
+ok($colors{Brown}, 'a52a2a'); # Brown in X
+ok($colors2{Brown}, 'a52a2a'); # Brown in X (don't try Netscape)
+ok($colors3{Brown}, 'a62a2a'); # Brown in Netscape (don't try X)
+
+# Test handling of non-existent color names
+
+ok(!defined $colors{NonExistentColourName});
+ok(!exists $colors{NonExistentColourName});
+
@@ -1,22 +1,20 @@ -use Test; - -BEGIN { plan tests => 4, todo => [ ] } - -use strict; -use Carp; - -use Graphics::ColorNames 0.32, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames', 'X'; -ok(1); - -ok(keys %colors, 760); # - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); +#!/usr/bin/perl
+
+use strict;
+
+use Test::More tests => 4;
+
+use_ok('Graphics::ColorNames', 0.32, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames', 'X';
+ok(tied %colors);
+
+ok(keys %colors == 760); #
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
diff --git a/t/03-HTML.t b/t/03-HTML.t index 5b5cee2..f59d6dd 100644 --- a/t/03-HTML.t +++ b/t/03-HTML.t @@ -1,26 +1,23 @@ -use Test; - -BEGIN { plan tests => 7, todo => [ ] } - -use strict; -use Carp; - -use Graphics::ColorNames 0.20, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames', 'HTML'; -ok(1); - -ok(keys %colors, 17); - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); - -ok(exists($colors{"fuchsia"})); -ok(exists($colors{"fuscia"})); -ok($colors{"fuscia"} eq $colors{"fuchsia"});
\ No newline at end of file +#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 7;
+
+use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames', 'HTML';
+ok(tied %colors);
+
+ok(keys %colors == 17);
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
+
+ok(exists($colors{"fuchsia"}));
+ok(exists($colors{"fuscia"}));
+ok($colors{"fuscia"} eq $colors{"fuchsia"});
diff --git a/t/04-Windows.t b/t/04-Windows.t index 6a78a6d..870c19c 100644 --- a/t/04-Windows.t +++ b/t/04-Windows.t @@ -1,22 +1,20 @@ -use Test; - -BEGIN { plan tests => 4, todo => [ ] } - -use strict; -use Carp; - -use Graphics::ColorNames 0.20, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames', 'Windows'; -ok(1); - -ok(keys %colors, 16); - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); +#!/usr/buin/perl
+
+use strict;
+
+use Test::More tests => 4;
+
+use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames', 'Windows';
+ok(tied %colors);
+
+ok(keys %colors == 16);
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
diff --git a/t/05-Netscape.t b/t/05-Netscape.t index 0285dd7..d3f7922 100644 --- a/t/05-Netscape.t +++ b/t/05-Netscape.t @@ -1,28 +1,29 @@ -use Test; - -BEGIN { plan tests => 7, todo => [ 5, 6, 7 ] } - -use strict; -use Carp; - -use Graphics::ColorNames 0.32, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames', 'Netscape'; -ok(1); - -ok(keys %colors, 100); # - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); - -# Problem is with Netscape's color definitions - -ok($colors{gold} ne $colors{mediumblue}); -ok($colors{lightblue} ne $colors{mediumblue}); -ok($colors{lightblue} ne $colors{gold}); +#!/usr/bin/perl
+
+use strict;
+
+use Test::More tests => 7;
+
+use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames', 'Netscape';
+ok(tied %colors);
+
+ok(keys %colors == 100); #
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
+
+# Problem is with Netscape's color definitions
+
+{
+ local $TODO = "Problem with Netscape color definitions";
+ ok($colors{gold} ne $colors{mediumblue});
+ ok($colors{lightblue} ne $colors{mediumblue});
+ ok($colors{lightblue} ne $colors{gold});
+}
@@ -1,47 +1,47 @@ - -use strict; -use warnings; - -use constant TEST_CASES => { - "black" => 0x000000, - "red" => 0xff0000, - "green" => 0x00ff00, - "blue" => 0x0000ff, - "white" => 0xffffff, -}; - -use Test::More tests => 3 + (9 * 5); - -use_ok('Graphics::ColorNames', (qw(tuple2hex))); - -my $rgb = Graphics::ColorNames->new(qw( X )); -ok(defined $rgb); -ok($rgb->isa('Graphics::ColorNames')); - -my $tests = TEST_CASES; - -foreach my $name (keys %$tests) { - - my $a = $rgb->hex($name, '0x'); - ok( $a =~ /^0x[0-9a-f]{6}$/i ); - ok( eval($a) == $tests->{$name}, "Testing color $name" ); - - my $b = $rgb->hex($name, '#'); - ok( $b =~ /^\x23[0-9a-f]{6}$/i ); - - my $c = $rgb->hex($name, ""); - ok( $c =~ /^[0-9a-f]{6}$/i ); - - $c = $rgb->hex($name); - ok( $c =~ /^[0-9a-f]{6}$/i ); - - my $d = $rgb->rgb($name, ','); - ok( $d =~ /^\d{1,3}(\,\d{1,3}){2}$/ ); - - my @v = $rgb->rgb($name); - ok( @v == 3 ); - - ok( join(',', @v) eq $d ); - ok( tuple2hex(@v) eq $c ); - -} +#!/usr/bin/perl
+
+use strict;
+
+use constant TEST_CASES => {
+ "black" => 0x000000,
+ "red" => 0xff0000,
+ "green" => 0x00ff00,
+ "blue" => 0x0000ff,
+ "white" => 0xffffff,
+};
+
+use Test::More tests => 3 + (9 * 5);
+
+use_ok('Graphics::ColorNames', 1.06, (qw(tuple2hex)));
+
+my $rgb = Graphics::ColorNames->new(qw( X ));
+ok(defined $rgb);
+ok($rgb->isa('Graphics::ColorNames'));
+
+my $tests = TEST_CASES;
+
+foreach my $name (keys %$tests) {
+
+ my $a = $rgb->hex($name, '0x');
+ ok( $a =~ /^0x[0-9a-f]{6}$/i );
+ ok( eval($a) == $tests->{$name}, "Testing color $name" );
+
+ my $b = $rgb->hex($name, '#');
+ ok( $b =~ /^\x23[0-9a-f]{6}$/i );
+
+ my $c = $rgb->hex($name, "");
+ ok( $c =~ /^[0-9a-f]{6}$/i );
+
+ $c = $rgb->hex($name);
+ ok( $c =~ /^[0-9a-f]{6}$/i );
+
+ my $d = $rgb->rgb($name, ',');
+ ok( $d =~ /^\d{1,3}(\,\d{1,3}){2}$/ );
+
+ my @v = $rgb->rgb($name);
+ ok( @v == 3 );
+
+ ok( join(',', @v) eq $d );
+ ok( tuple2hex(@v) eq $c );
+
+}
diff --git a/t/07-file.t b/t/07-file.t index 3f5ce06..075403a 100644 --- a/t/07-file.t +++ b/t/07-file.t @@ -1,26 +1,24 @@ -use Test; - -BEGIN { plan tests => 10, todo => [ ] } - -use strict; -use Carp; - -use Graphics::ColorNames 0.39, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames', './t/rgb.txt'; -ok(1); - -ok(keys %colors, 6); # - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); - -foreach my $name (qw( one two three four five six)) { - ok(exists $colors{$name}); -} +#!/usr/bin/perl
+
+use strict;
+
+use Test::More tests => 10;
+
+use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames', './t/rgb.txt';
+ok(tied %colors);
+
+ok(keys %colors == 6); #
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
+
+foreach my $name (qw( one two three four five six)) {
+ ok(exists $colors{$name});
+}
diff --git a/t/08-filehandle.t b/t/08-filehandle.t index 6b46b04..ce3aec7 100644 --- a/t/08-filehandle.t +++ b/t/08-filehandle.t @@ -1,30 +1,28 @@ -use Test; - -BEGIN { plan tests => 10, todo => [ ] } - -use strict; -use Carp; -use IO::File; - -my $fh = new IO::File; -open($fh, './t/rgb.txt'); - -use Graphics::ColorNames 0.39, qw( hex2tuple tuple2hex ); -ok(1); - -tie my %colors, 'Graphics::ColorNames', $fh; -ok(1); - -ok(keys %colors, 6); # - -my $count = 0; -foreach my $name (keys %colors) - { - my @RGB = hex2tuple( $colors{$name} ); - $count++, if (tuple2hex(@RGB) eq $colors{$name} ); - } -ok($count, keys %colors); - -foreach my $name (qw( one two three four five six)) { - ok(exists $colors{$name}); -} +#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 10;
+
+use IO::File;
+
+my $fh = new IO::File;
+open($fh, './t/rgb.txt');
+
+use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+
+tie my %colors, 'Graphics::ColorNames', $fh;
+ok(tied %colors);
+
+ok(keys %colors == 6); #
+
+my $count = 0;
+foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ok($count == keys %colors);
+
+foreach my $name (qw( one two three four five six)) {
+ ok(exists $colors{$name});
+}
|