#!/usr/bin/perl -T
our
$tests
;
BEGIN { ++
$INC
{
'tests.pm'
} }
sub
tests'VERSION {
$tests
+=
pop
};
plan
tests
=>
$tests
;
use_ok
'CSS::DOM::Rule::Style'
,;
my
$rule
= (
my
$ss
= CSS::DOM
'parse('
a{text-decoration: none} p { margin: 0 }')
)-> cssRules->[0];
isa_ok
$rule
,
'CSS::DOM::Rule::Style'
;
{
(
my
$ss
= new CSS::DOM)->insertRule(
'a{}'
,0);
my
$rule
=
$ss
->cssRules->[0];
my
$empty_rule
= new CSS::DOM::Rule::Style
$rule
;
isa_ok
$empty_rule
,
'CSS::DOM::Rule::Style'
,
'result of new CSS::DOM::Rule::Style (empty rule)'
;
is
$empty_rule
->parentRule,
$rule
,
'parentRule of empty rule'
;
is
$empty_rule
->parentStyleSheet,
$ss
,
'parentStyleSheet of empty rule'
;
is
$empty_rule
->type,
&CSS::DOM::Rule::STYLE_RULE
,
'type of empty rule'
;
$empty_rule
= new CSS::DOM::Rule::Style
$ss
;
isa_ok
$empty_rule
,
'CSS::DOM::Rule::Style'
,
'empty rule with no parent rule'
;
is +()=
$empty_rule
->parentRule, 0,
'parentRule of empty rule without parent rule'
;
is
$empty_rule
->parentStyleSheet,
$ss
,
'parentStyleSheet of empty rule w/no parent rule'
;
}
{
$ss
->insertRule('*, a, b i, p > ul, div:first-child, a:
link
,
a:visited, a:active, a:hover, a:focus, em:lang(en),
tr
+td,
html[version], body[style=
"margin: 0"
],
table[class~=\'foo\'], strong[lang|=
"en"
], a.bbbb, .ed,
img
0);
is +(
my
$rule
=
$ss
->cssRules->[0])->selectorText,
'*, a, b i, p > ul, div:first-child, a:
link
,
a:visited, a:active, a:hover, a:focus, em:lang(en),
tr
+td,
html[version], body[style=
"margin: 0"
],
table[class~=\'foo\'], strong[lang|=
"en"
], a.bbbb, .ed,
img
'selectorText'
;
is
$rule
->selectorText(
'address'
),
'*, a, b i, p > ul, div:first-child, a:
link
,
a:visited, a:active, a:hover, a:focus, em:lang(en),
tr
+td,
html[version], body[style=
"margin: 0"
],
table[class~=\'foo\'], strong[lang|=
"en"
], a.bbbb, .ed,
img
'get/set selectorText'
;
is
$rule
->selectorText,
'address'
,
'get selectorText again'
;
}
isa_ok style
$rule
,
'CSS::DOM::Style'
,
'ret val of style'
;
is style
$rule
->textDecoration,
'none'
,
'the style decl does have the css stuff, so it’s the right one'
;