Lines 2-7
Link Here
|
2 |
|
2 |
|
3 |
|
3 |
|
4 |
use Test; |
4 |
use Test; |
|
|
5 |
use strict; |
6 |
use warnings; |
5 |
|
7 |
|
6 |
BEGIN { plan tests => 34 } |
8 |
BEGIN { plan tests => 34 } |
7 |
|
9 |
|
Lines 20-26
Link Here
|
20 |
|
22 |
|
21 |
## Test object creation |
23 |
## Test object creation |
22 |
|
24 |
|
23 |
$obj = HTML::TableContentParser->new(); |
25 |
my $obj = HTML::TableContentParser->new(); |
24 |
ok(defined $obj, 1, $@); |
26 |
ok(defined $obj, 1, $@); |
25 |
|
27 |
|
26 |
|
28 |
|
Lines 29-42
Link Here
|
29 |
## the correct values to the callback. |
31 |
## the correct values to the callback. |
30 |
|
32 |
|
31 |
|
33 |
|
32 |
$table_caption = 'This is a caption'; |
34 |
my $table_caption = 'This is a caption'; |
33 |
$table_content1 = 'This is table cell content 1'; |
35 |
my $table_content1 = 'This is table cell content 1'; |
34 |
$table_content2 = 'This is table cell content 2'; |
36 |
my $table_content2 = 'This is table cell content 2'; |
35 |
$table_content3 = '<a href="SomeLink">This is table cell content 3, a link</a>'; |
37 |
my $table_content3 = '<a href="SomeLink">This is table cell content 3, a link</a>'; |
36 |
$table_content4 = 'Some more text wrapping <a href="SomeLink">This is table cell content 4</a> a link.'; |
38 |
my $table_content4 = 'Some more text wrapping <a href="SomeLink">This is table cell content 4</a> a link.'; |
37 |
$header_text = 'Header text'; |
39 |
my $header_text = 'Header text'; |
38 |
|
40 |
|
39 |
$html = qq{ |
41 |
my $html = qq{ |
40 |
<html> |
42 |
<html> |
41 |
<head> |
43 |
<head> |
42 |
</head> |
44 |
</head> |
Lines 59-65
Link Here
|
59 |
|
61 |
|
60 |
|
62 |
|
61 |
$HTML::TableContentParser::DEBUG = 0; |
63 |
$HTML::TableContentParser::DEBUG = 0; |
62 |
$tables = $obj->parse($html); |
64 |
my $tables = $obj->parse($html); |
63 |
ok($tables->[0]->{caption}->{data}, $table_caption, $@); |
65 |
ok($tables->[0]->{caption}->{data}, $table_caption, $@); |
64 |
ok($tables->[0]->{rows}->[0]->{cells}->[0]->{data}, $table_content1, $@); |
66 |
ok($tables->[0]->{rows}->[0]->{cells}->[0]->{data}, $table_content1, $@); |
65 |
ok($tables->[0]->{rows}->[1]->{cells}->[0]->{data}, $table_content2, $@); |
67 |
ok($tables->[0]->{rows}->[1]->{cells}->[0]->{data}, $table_content2, $@); |
Lines 124-139
Link Here
|
124 |
ok(@$tables, 2, @_); |
126 |
ok(@$tables, 2, @_); |
125 |
|
127 |
|
126 |
## and three headers for each table |
128 |
## and three headers for each table |
127 |
for $t (0..$#{@$tables}) { |
129 |
for my $t (0..(@$tables-1)) { |
128 |
for (0..$#hdrs) { |
130 |
for (0..2) { |
129 |
ok($tables->[$t]->{headers}->[$_]->{data}, $hdrs[$_], $@); |
131 |
# ok($t, $t); |
|
|
132 |
ok($tables->[$t]->{headers}->[$_]->{data}, $hdrs[$_], $@); |
130 |
} |
133 |
} |
131 |
} |
134 |
} |
132 |
|
135 |
|
133 |
|
136 |
|
134 |
## and three rows of three cells each, for each table.. (18 total). |
137 |
## and three rows of three cells each, for each table.. (18 total). |
135 |
for $t (0..$#{@$tables}) { |
138 |
for my $t (0..1) { |
136 |
for $r (0..$#rows) { |
139 |
for my $r (0..$#rows) { |
137 |
for (0..2) { |
140 |
for (0..2) { |
138 |
ok($tables->[$t]->{rows}->[$r]->{cells}->[$_]->{data}, $rows[$r]->[$_], $@); |
141 |
ok($tables->[$t]->{rows}->[$r]->{cells}->[$_]->{data}, $rows[$r]->[$_], $@); |
139 |
} |
142 |
} |