|
Revision 2188, 1.5 kB
(checked in by karpet, 2 weeks ago)
|
first pass at the dom-specific property and metaname feature.
|
| Line | |
|---|
| 1 |
#!/usr/bin/perl |
|---|
| 2 |
|
|---|
| 3 |
use strict; |
|---|
| 4 |
use warnings; |
|---|
| 5 |
use Test::More tests => 26; |
|---|
| 6 |
use SwishTestUtils; |
|---|
| 7 |
|
|---|
| 8 |
my %docs = ( |
|---|
| 9 |
'UPPERlower.XML' => '19', |
|---|
| 10 |
'badxml.xml' => '10', |
|---|
| 11 |
'contractions.xml' => '13', |
|---|
| 12 |
'foo.txt' => '16', |
|---|
| 13 |
'latin1.xml' => '3', |
|---|
| 14 |
'latin1.txt' => '3', |
|---|
| 15 |
'min.txt' => '1', |
|---|
| 16 |
'multi_props.xml' => '25', |
|---|
| 17 |
'nested_meta.xml' => '18', |
|---|
| 18 |
't.html' => '6', |
|---|
| 19 |
'testutf.xml' => '8754', |
|---|
| 20 |
'utf.xml' => '30', |
|---|
| 21 |
'words.txt' => '55', |
|---|
| 22 |
'words.xml' => '52', |
|---|
| 23 |
'has_nulls.txt' => '13', |
|---|
| 24 |
'no_such_file.txt' => '0', |
|---|
| 25 |
'meta.html' => '23', |
|---|
| 26 |
'empty_doc.html' => '0', |
|---|
| 27 |
'no_words.html' => '0', |
|---|
| 28 |
'html_broken.html' => '2', |
|---|
| 29 |
'properties.html' => 19, |
|---|
| 30 |
'inline.xml' => 12, |
|---|
| 31 |
'inline.html' => 9, |
|---|
| 32 |
'dom.xml' => 3, |
|---|
| 33 |
|
|---|
| 34 |
); |
|---|
| 35 |
|
|---|
| 36 |
my %stdindocs = ( |
|---|
| 37 |
'doc.xml' => '8407', |
|---|
| 38 |
'test.txt' => 1, |
|---|
| 39 |
|
|---|
| 40 |
); |
|---|
| 41 |
|
|---|
| 42 |
for my $file ( sort keys %docs ) { |
|---|
| 43 |
cmp_ok( words($file), '==', $docs{$file}, "$file -> $docs{$file} words" ); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
for my $file ( sort keys %stdindocs ) { |
|---|
| 47 |
cmp_ok( fromstdin($file), '==', $stdindocs{$file}, |
|---|
| 48 |
"stdin $file -> $stdindocs{$file} words" ); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
sub words { |
|---|
| 52 |
my $file = shift; |
|---|
| 53 |
my $o = join( ' ', `./swish_lint test_docs/$file` ); |
|---|
| 54 |
my ($count) = ( $o =~ m/nwords: (\d+)/ ); |
|---|
| 55 |
return $count || 0; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
sub fromstdin { |
|---|
| 59 |
my $file = shift; |
|---|
| 60 |
my $o = join( ' ', `./swish_lint - < test_stdin/$file` ); |
|---|
| 61 |
my ($count) = ( $o =~ m/total words: (\d+)/ ); |
|---|
| 62 |
return $count || 0; |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|