Drop minimum perl version from 5.14.0 to 5.8.9
[convert-color-husl.git] / t / Convert-Color-HUSL.t
CommitLineData
1f72b051 1#!/usr/bin/perl
4e59696a
MG
2use 5.008009;
3use strict;
1f72b051
MG
4use warnings;
5
6use Convert::Color::RGB8;
7use JSON::PP qw/decode_json/;
3d128ec5 8use Test::More tests => 5 * 4096;
1f72b051 9
3d128ec5
MG
10use constant EPSILON => $ENV{RELEASE_TESTING} ? 1e-11 : 2e-4;
11my @spaces = qw/XYZ LUV LCh HUSL HUSLp/;
1f72b051
MG
12
13sub isf {
14 my ($x, $y, $name) = @_;
3d128ec5 15 ok !grep({ abs ($_ - shift @$y) > EPSILON } @$x), $name;
1f72b051
MG
16}
17
3d128ec5
MG
18if ($ENV{RELEASE_TESTING}) {
19 require JSON::MaybeXS;
20 open my $fh, '<', 't/snapshot-rev4.json';
21 my $snapshot = join '', <$fh>;
22
23 my %tests = %{JSON::MaybeXS::decode_json $snapshot};
24
25 for my $color (sort keys %tests) {
26 my $col = Convert::Color::RGB8->new(substr $color, 1);
27 isf $col->convert_to(lc), $tests{$color}{lc()}, "convert $color to $_" for @spaces;
28 }
29} else {
30 open my $fh, '<', 't/snapshot-rev4.csv';
31 <$fh>;
32
33 while (<$fh>) {
34 my ($color, @good) = split ',';
35 my $col = Convert::Color::RGB8->new($color);
36 isf $col->convert_to(lc), \@good, "convert $color to $_" for @spaces
37 }
1f72b051 38}
This page took 0.014116 seconds and 4 git commands to generate.