File: css-dom.t

package info (click to toggle)
libcss-dom-perl 0.17-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,044 kB
  • sloc: perl: 7,310; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -T

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

use tests 2;
require CSS::DOM;
my $u = \'u';
my $p = \'p';
my $sheet = new CSS::DOM url_fetcher => $u, property_parser => $p;
is $sheet->url_fetcher, $u, 'url_fetcher';
is $sheet->property_parser, $p, 'property_parser';

use tests 1; # compute_style
{
 # compute_style actually expects an HTML::DOM::Element, but HTML::DOM
 # depends on CSS::DOM, so we cannot easily test it without a recursive
 # dependency.  So we use a dummy class.
 package MyElem;
 AUTOLOAD { $_[0]{(our $AUTOLOAD =~ /.*::(.*)/)[0]} }
}
{
 my $w;
 local $SIG{__WARN__} = sub { $w .= shift };
 require CSS::DOM::Style;
 my $elem = bless{
  style => CSS::DOM::Style::parse('color:red'), tagName => 'p',
 }, MyElem=>;
 CSS::DOM::compute_style(element => $elem);
 is $w, undef, 'no warnings for style belonging to element itself';
 # This warning used to occur (before 0.15) if no applicable property with
 # the same name was to be found in the style sheets.
}