CSS-DOM

 view release on metacpan or  search on metacpan

t/CSS2Properties.t  view on Meta::CPAN

#!/usr/bin/perl -T

use strict; use warnings;
our $tests;
BEGIN { ++$INC{'tests.pm'} }
sub tests'VERSION { $tests += pop };
sub tests'import { $tests += pop if @_ > 1 };
use Test::More;
plan tests => $tests;

BEGIN {
our @props = qw /azimuth background background-attachment background-color background-image background-position background-repeat border border-bottom border-bottom-color border-bottom-style border-bottom-width border-collapse border-color border-lef...
}

require CSS::DOM::Style;
my $decl = CSS::DOM::Style::parse
 ( join('', map"$_: 65;", our @props) );

use tests +4 * our @props; # normal CSS property methods
for (@props) {
	(my $meth = $_) =~ s/-(.)/\u$1/g;
	is $decl->$meth, '65', "get $meth";
	is $decl->$meth('right'), '65', "get/set $meth";
	is $decl->getPropertyValue($_), 'right',
		"result of setting $meth";
	is $decl->$meth, 'right', "get $meth again";
}

use tests 4; # cssFloat: the weird case
is $decl->cssFloat, 'right', "get cssFloat"; # it was set by the float meth
is $decl->cssFloat('left'), 'right', "get/set cssFloat";
is $decl->getPropertyValue('float'), 'left',
	"result of setting cssFloat";
is $decl->cssFloat, 'left', "get cssFloat again";

use tests 8; # assigning '', ' ', ' foo' (bug in 0.06)
is eval {$decl->cssFloat(''); 1}, 1,'empty string assignment doesn\'t die';
is $decl->cssFloat, '', 'empty string assignment works';
$decl->cssFloat('foo');
is eval {$decl->cssFloat(' '); 1},1,'whitespace assignment doesn\'t die';
is $decl->cssFloat, '', 'whitespace assignment works';
$decl->cssFloat('foo');
is eval{$decl->cssFloat('/*foo*/'); 1},1,'comment assignment doesn\'t die';
is $decl->cssFloat, '', 'comment assignment works';
is eval{$decl->cssFloat(' foo'); 1},1,'" foo" assignment doesn\'t die';
is $decl->cssFloat, ' foo', 'assignment with initial whitespace works';



( run in 0.477 second using v1.01-cache-2.11-cpan-e93a5daba3e )