1#!/usr/bin/perl 2 3use strict; 4use warnings; 5 6use Test::More; 7 8use Convert::Color::HSL; 9 10my $red = Convert::Color::HSL->new( 0, 1, 0.5 ); 11 12is( $red->hue, 0, 'red hue' ); 13is( $red->saturation, 1, 'red saturation' ); 14is( $red->lightness, 0.5, 'red lightness' ); 15 16is( $red->chroma, 1, 'red chroma' ); 17 18is_deeply( [ $red->hsl ], [ 0, 1, 0.5 ], 'red hsl' ); 19 20my $green = Convert::Color::HSL->new( 120, 1, 0.5 ); 21 22is( $green->hue, 120, 'green hue' ); 23is( $green->saturation, 1, 'green saturation' ); 24is( $green->lightness, 0.5, 'green lightness' ); 25 26is( $green->chroma, 1, 'green chroma' ); 27 28is_deeply( [ $green->hsl ], [ 120, 1, 0.5 ], 'green hsl' ); 29 30my $blue = Convert::Color::HSL->new( 240, 1, 0.5 ); 31 32is( $blue->hue, 240, 'blue hue' ); 33is( $blue->saturation, 1, 'blue saturation' ); 34is( $blue->lightness, 0.5, 'blue lightness' ); 35 36is( $blue->chroma, 1, 'blue chroma' ); 37 38is_deeply( [ $blue->hsl ], [ 240, 1, 0.5 ], 'blue hsl' ); 39 40my $yellow = Convert::Color::HSL->new( '60,1,0.5' ); 41 42is( $yellow->hue, 60, 'yellow hue' ); 43is( $yellow->saturation, 1, 'yellow saturation' ); 44is( $yellow->lightness, 0.5, 'yellow lightness' ); 45 46is( $yellow->chroma, 1, 'yellow chroma' ); 47 48is_deeply( [ $yellow->hsl ], [ 60, 1, 0.5 ], 'yellow hsl' ); 49 50# "black" is anything at value 0 51my $black = Convert::Color::HSL->new( '0,1,0' ); 52 53is( $black->saturation, 1, 'black saturation' ); 54is( $black->lightness, 0, 'black lightness' ); 55 56is( $black->chroma, 0, 'black chroma' ); 57 58# "white" is anything at value 1 59my $white = Convert::Color::HSL->new( '0,1,1' ); 60 61is( $white->saturation, 1, 'white saturation' ); 62is( $white->lightness, 1, 'white lightness' ); 63 64is( $white->chroma, 0, 'white chroma' ); 65 66done_testing; 67