File: MediaList.t

package info (click to toggle)
libcss-dom-perl 0.15-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 716 kB
  • ctags: 249
  • sloc: perl: 7,310; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,509 bytes parent folder | download | duplicates (7)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/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 1; # use
use_ok 'CSS::DOM::MediaList';

use tests 2; # constructor
isa_ok +(my $ml = new CSS::DOM::MediaList 'print', 'screen'), 
	'CSS::DOM::MediaList';
is_deeply [@$ml], ['print' ,'screen'], 'constructor args';

use tests 3; # mediaText
is mediaText $ml, 'print, screen', 'initial value of mediaText';
is +(mediaText $ml " \nscReen (big one),\xa0hologram-101 "),
	'print, screen', 'ret val of mediaText with args';
is_deeply [@$ml], ['scReen', 'hologram-101'],
	'result of setting mediaText';

use tests 1; # length
is $ml->length, 2, 'length';

use tests 1; # item
is +(item $ml 1), 'hologram-101', 'item';

use tests 4; # deleteMedium
is +()=$ml->deleteMedium('hologram-101'), 0, 'ret val of deleteMedium';
is_deeply [@$ml], ['scReen'], 'effect of deleteMedium';
eval { deleteMedium $ml 'foo' };
isa_ok $@, 'CSS::DOM::Exception',
	'$@ (after deleteMedium)';
cmp_ok $@, '==', 
	&CSS::DOM::Exception::NOT_FOUND_ERR,
	'deleteMedium throws a "not found" error';

use tests 3; # appendMedium
@$ml = qw[ foo bar baz ];
is +()=$ml->appendMedium('bop'), 0, 'ret val of appendMedium';
is_deeply [@$ml], [qw [ foo bar baz bop ]], 'effect thereof';
$ml->appendMedium('bar');
is_deeply [@$ml], [qw[ foo baz bop bar ]],
	'appendMedium deletes the item first';

# What do you call a psychic midget escaped from prison?
# A small medium at large.