On Sun Jun 01 15:36:33 2014, PEVANS wrote:
Show quoted text> Hmm, despite having a long-double Perl build, I haven't actually been
> able to replicate this one. However, I can copy out the same
> approximate-number test I use in the other test files into this one
> too; that should solve it.
This is actually quite neat with Test::Number::Delta.
Patch attached.
--
Paul Evans
=== modified file 'Build.PL'
--- Build.PL 2013-05-10 15:57:48 +0000
+++ Build.PL 2014-06-01 19:55:53 +0000
@@ -11,6 +11,7 @@
},
build_requires => {
'Test::More' => '0.88', # done_testing
+ 'Test::Number::Delta' => 0,
},
auto_configure_requires => 0, # Don't add M::B to configure_requires
license => 'perl',
=== modified file 't/22rgb-dst.t'
--- t/22rgb-dst.t 2013-05-10 12:37:08 +0000
+++ t/22rgb-dst.t 2014-06-01 19:55:53 +0000
@@ -4,6 +4,7 @@
use warnings;
use Test::More;
+use Test::Number::Delta;
use Convert::Color::RGB;
use Convert::Color::RGB8;
@@ -17,9 +18,9 @@
is( $black->dst_rgb( $black ), 0, 'black->dst_rgb black' );
-is( $black->dst_rgb( $red ), 1/sqrt(3), 'black->dst_rgb red' );
-is( $black->dst_rgb( $green ), 1/sqrt(3), 'black->dst_rgb green' );
-is( $black->dst_rgb( $blue ), 1/sqrt(3), 'black->dst_rgb blue' );
+delta_ok( $black->dst_rgb( $red ), 1/sqrt(3), 'black->dst_rgb red' );
+delta_ok( $black->dst_rgb( $green ), 1/sqrt(3), 'black->dst_rgb green' );
+delta_ok( $black->dst_rgb( $blue ), 1/sqrt(3), 'black->dst_rgb blue' );
is( $black->dst_rgb( $white ), 1, 'black->dst_rgb white' );
@@ -40,9 +41,9 @@
is( $black8->dst_rgb8( $black8 ), 0, 'black8->dst_rgb8 black8' );
is( $black8->dst_rgb8( $black ), 0, 'black8->dst_rgb8 black' );
-is( $black8->dst_rgb8( $red8 ), 1/sqrt(3), 'black8->dst_rgb8 red8' );
-is( $black8->dst_rgb8( $green8 ), 1/sqrt(3), 'black8->dst_rgb8 green8' );
-is( $black8->dst_rgb8( $blue8 ), 1/sqrt(3), 'black8->dst_rgb8 blue8' );
+delta_ok( $black8->dst_rgb8( $red8 ), 1/sqrt(3), 'black8->dst_rgb8 red8' );
+delta_ok( $black8->dst_rgb8( $green8 ), 1/sqrt(3), 'black8->dst_rgb8 green8' );
+delta_ok( $black8->dst_rgb8( $blue8 ), 1/sqrt(3), 'black8->dst_rgb8 blue8' );
is( $black8->dst_rgb8( $white8 ), 1, 'black8->dst_rgb8 white8' );
is( $black8->dst_rgb8( $white ), 1, 'black8->dst_rgb8 white' );
=== modified file 't/23hsv-dst.t'
--- t/23hsv-dst.t 2013-05-10 15:11:55 +0000
+++ t/23hsv-dst.t 2014-06-01 19:55:53 +0000
@@ -4,6 +4,7 @@
use warnings;
use Test::More;
+use Test::Number::Delta;
use Convert::Color::HSV;
@@ -14,21 +15,13 @@
my $cyan = Convert::Color::HSV->new( 180, 1, 1 );
my $blue = Convert::Color::HSV->new( 240, 1, 1 );
-sub about
-{
- my ( $got, $expect, $name ) = @_;
-
- ok( abs( $got - $expect ) < 0.000001, $name ) or
- diag( "got $got, expected $expect" );
-}
-
is( $black->dst_hsv( $black ), 0, 'black->dst_hsv black' );
-about( $black->dst_hsv( $red ), 1/sqrt(2), 'black->dst_hsv red' );
-about( $black->dst_hsv( $green ), 1/sqrt(2), 'black->dst_hsv green' );
-about( $black->dst_hsv( $blue ), 1/sqrt(2), 'black->dst_hsv blue' );
+delta_ok( $black->dst_hsv( $red ), 1/sqrt(2), 'black->dst_hsv red' );
+delta_ok( $black->dst_hsv( $green ), 1/sqrt(2), 'black->dst_hsv green' );
+delta_ok( $black->dst_hsv( $blue ), 1/sqrt(2), 'black->dst_hsv blue' );
-about( $black->dst_hsv( $white ), 1/2, 'black->dst_hsv white' );
+delta_ok( $black->dst_hsv( $white ), 1/2, 'black->dst_hsv white' );
is( $red->dst_hsv( $cyan ), 1, 'red->dst_hsv cyan' );
=== modified file 't/24hsl-dst.t'
--- t/24hsl-dst.t 2013-05-10 15:11:55 +0000
+++ t/24hsl-dst.t 2014-06-01 19:55:53 +0000
@@ -4,6 +4,7 @@
use warnings;
use Test::More;
+use Test::Number::Delta;
use Convert::Color::HSL;
@@ -14,21 +15,13 @@
my $cyan = Convert::Color::HSL->new( 180, 1, 0.5 );
my $blue = Convert::Color::HSL->new( 240, 1, 0.5 );
-sub about
-{
- my ( $got, $expect, $name ) = @_;
-
- ok( abs( $got - $expect ) < 0.000001, $name ) or
- diag( "got $got, expected $expect" );
-}
-
is( $black->dst_hsl( $black ), 0, 'black->dst_hsl black' );
-about( $black->dst_hsl( $red ), sqrt(1.25/4), 'black->dst_hsl red' );
-about( $black->dst_hsl( $green ), sqrt(1.25/4), 'black->dst_hsl green' );
-about( $black->dst_hsl( $blue ), sqrt(1.25/4), 'black->dst_hsl blue' );
+delta_ok( $black->dst_hsl( $red ), sqrt(1.25/4), 'black->dst_hsl red' );
+delta_ok( $black->dst_hsl( $green ), sqrt(1.25/4), 'black->dst_hsl green' );
+delta_ok( $black->dst_hsl( $blue ), sqrt(1.25/4), 'black->dst_hsl blue' );
-about( $black->dst_hsl( $white ), 0.5, 'black->dst_hsl white' );
+delta_ok( $black->dst_hsl( $white ), 0.5, 'black->dst_hsl white' );
is( $red->dst_hsl( $cyan ), 1, 'red->dst_hsl cyan' );