|
Revision 2178, 1.3 kB
(checked in by karpet, 2 months ago)
|
some versions of html parser were passing through extra whitespace.
seems to be a specific libxml2 issue. in any case, added a new
whitespace check in both add to buf methods and perl bindings
(the latter where t/20-metanames.t was failing due to extra whitespace)
|
| Line | |
|---|
| 1 |
use strict; |
|---|
| 2 |
use warnings; |
|---|
| 3 |
|
|---|
| 4 |
use Test::More tests => 28; |
|---|
| 5 |
use Data::Dump qw( dump ); |
|---|
| 6 |
|
|---|
| 7 |
use_ok('SWISH::3'); |
|---|
| 8 |
|
|---|
| 9 |
ok( my $s3 = SWISH::3->new( |
|---|
| 10 |
config => '<swish><MetaNames><foo /></MetaNames></swish>', |
|---|
| 11 |
handler => \&getmeta |
|---|
| 12 |
), |
|---|
| 13 |
"new parser" |
|---|
| 14 |
); |
|---|
| 15 |
|
|---|
| 16 |
my $r = 0; |
|---|
| 17 |
while ( $r < 10 ) { |
|---|
| 18 |
ok( $r += $s3->parse_file("t/test.html"), "parse HTML" ); |
|---|
| 19 |
|
|---|
| 20 |
#diag("r = $r"); |
|---|
| 21 |
} |
|---|
| 22 |
$r = 0; |
|---|
| 23 |
while ( $r < 10 ) { |
|---|
| 24 |
ok( $r += $s3->parse_file("t/test.xml"), "parse XML" ); |
|---|
| 25 |
|
|---|
| 26 |
#diag("r = $r"); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
sub getmeta { |
|---|
| 30 |
my $data = shift; |
|---|
| 31 |
|
|---|
| 32 |
#diag(dump($data->metanames)); |
|---|
| 33 |
|
|---|
| 34 |
#$data->tokens->debug; |
|---|
| 35 |
|
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
ok( $s3 = SWISH::3->new( |
|---|
| 39 |
config => '<swish><MetaNames><foo /></MetaNames></swish>', |
|---|
| 40 |
handler => \&metacheck |
|---|
| 41 |
), |
|---|
| 42 |
"new s3" |
|---|
| 43 |
); |
|---|
| 44 |
ok( $s3->parse_file("t/bumper.html"), "parse bumper.html" ); |
|---|
| 45 |
|
|---|
| 46 |
sub metacheck { |
|---|
| 47 |
my $data = shift; |
|---|
| 48 |
my $meta = $data->metanames; |
|---|
| 49 |
my $prop = $data->properties; |
|---|
| 50 |
|
|---|
| 51 |
#dump $meta; |
|---|
| 52 |
#dump $prop; |
|---|
| 53 |
|
|---|
| 54 |
cmp_ok( $meta->{'foo'}->[0], 'eq', 'one two', "first foo meta" ); |
|---|
| 55 |
cmp_ok( $meta->{'foo'}->[1], 'eq', 'three four', "second foo meta" ); |
|---|
| 56 |
cmp_ok( |
|---|
| 57 |
$meta->{'swishdefault'}->[0], |
|---|
| 58 |
'eq', |
|---|
| 59 |
'this is para one', |
|---|
| 60 |
"first swishdefault meta" |
|---|
| 61 |
); |
|---|
| 62 |
cmp_ok( |
|---|
| 63 |
$meta->{'swishdefault'}->[1], |
|---|
| 64 |
'eq', |
|---|
| 65 |
'this is para two', |
|---|
| 66 |
"second swishdefault meta" |
|---|
| 67 |
); |
|---|
| 68 |
|
|---|
| 69 |
} |
|---|