Commit | Line | Data |
d3bcbd89 |
1 | use strict; |
2 | use warnings FATAL => 'all'; |
3 | |
4 | use HTML::Zoom; |
5 | use Test::More tests => 12; |
6 | |
7 | ok my $zoom = HTML::Zoom->from_html(<<HTML); |
8 | <html> |
9 | <head> |
10 | <title>Hi!</title> |
11 | </head> |
12 | <body id="content-area"> |
13 | <h1>Test</h1> |
14 | <div> |
15 | <p class="first-para">Some stuff</p> |
16 | <p class="boday-para">More stuff</p> |
17 | </div> |
18 | <p id="footer">Copryright 2222</p> |
19 | </body> |
20 | </html> |
21 | HTML |
22 | |
23 | ok my $fh = $zoom->to_fh, |
24 | 'got filehandle'; |
25 | |
26 | ok my $html = $zoom->to_html, |
27 | 'got html'; |
28 | |
29 | ok my $lines = join('', $zoom->to_fh->getlines), |
30 | 'got joined lines'; |
31 | |
32 | is $html, $lines, |
33 | 'straight html is same as lines'; |
34 | |
35 | { |
36 | $fh->read(my $buff, 2); |
37 | |
38 | ok $buff, |
39 | 'got a populated buffer'; |
40 | |
41 | is $buff, '<h', |
42 | 'got expected info in buffer'; |
43 | } |
44 | |
45 | { |
46 | $fh->read(my $buff, 4); |
47 | |
48 | ok $buff, |
49 | 'got a populated buffer'; |
50 | |
51 | is $buff, 'tml>', |
52 | 'got expected info in buffer'; |
53 | } |
54 | |
55 | { |
10a73720 |
56 | ##$fh->read(my $buff, 6, 20); |
57 | $fh->read(my $buff, 6, 14); |
d3bcbd89 |
58 | |
59 | ok $buff, |
60 | 'got a populated buffer'; |
61 | |
10a73720 |
62 | is $buff, '<title', |
d3bcbd89 |
63 | 'got expected info in buffer'; |
64 | } |
65 | |
66 | { |
67 | my @lines; |
68 | while($fh->read(my $buff, 15)) { |
69 | push @lines, $buff; |
70 | } |
71 | |
72 | is $#lines, 15, |
73 | 'correct number of lines'; |
74 | } |
d0e92e78 |
75 | |
3c5c4b9d |
76 | use Data::Dump 'dump'; |
77 | warn dump $fh->open; |
78 | warn dump open($fh); |
79 | warn dump $fh->stat; |
80 | warn dump ( -s $fh); |
d0e92e78 |
81 | |