3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 27; |
use Test::More tests => 28; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
|
use Data::Dumper; |
9 |
|
|
10 |
BEGIN { use_ok('Search::Estraier') }; |
BEGIN { use_ok('Search::Estraier') }; |
11 |
|
|
19 |
'size' => 42, |
'size' => 42, |
20 |
}; |
}; |
21 |
|
|
22 |
|
my @test_texts = ( |
23 |
|
'This is a test', |
24 |
|
'of pure-perl bindings', |
25 |
|
'for HyperEstraier' |
26 |
|
); |
27 |
|
|
28 |
ok(my $doc = new Search::Estraier::Document, 'new'); |
ok(my $doc = new Search::Estraier::Document, 'new'); |
29 |
|
|
30 |
isa_ok($doc, 'Search::Estraier::Document'); |
isa_ok($doc, 'Search::Estraier::Document'); |
41 |
cmp_ok($doc->attr($a), 'eq', $d, "attr $a = $d"); |
cmp_ok($doc->attr($a), 'eq', $d, "attr $a = $d"); |
42 |
} |
} |
43 |
|
|
44 |
ok($doc->add_text('This is a demo'), 'add_text'); |
foreach my $t (@test_texts) { |
45 |
|
ok($doc->add_text($t), "add_text: $t"); |
46 |
|
} |
47 |
|
|
48 |
ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text'); |
ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text'); |
49 |
|
|
50 |
throws_ok { my $text = $doc->texts } qr/return array/, 'texts scalar'; |
throws_ok { my $text = $doc->texts } qr/return array/, 'texts scalar'; |
72 |
ok($doc->add_attr($a, undef), "delete attribute"); |
ok($doc->add_attr($a, undef), "delete attribute"); |
73 |
} |
} |
74 |
|
|
75 |
@attr = $doc->attr_names, 'attr_names'; |
@attr = $doc->attr_names; |
76 |
#diag "attr_names left: ", join(',',$doc->attr_names), "\n"; |
#diag "attr_names left: ", join(',',$doc->attr_names), "\n"; |
77 |
cmp_ok(@attr, '==' , 0, "attributes removed"); |
cmp_ok(@attr, '==' , 0, "attributes removed"); |
78 |
|
|
79 |
diag "texts: ", join(',',@texts), "\n"; |
diag "texts: ", join(',',@texts), "\n"; |
80 |
|
ok(eq_array(\@test_texts, \@texts), 'texts'); |
81 |
|
|
82 |
cmp_ok(scalar @texts, '==', 1, 'texts'); |
diag Dumper(\@test_texts, \@texts); |
83 |
|
|
84 |
SKIP: { |
SKIP: { |
85 |
skip "est_keywords not implemented", 2; |
skip "est_keywords not implemented", 2; |
95 |
#diag "make_snippet:\n$snippet"; |
#diag "make_snippet:\n$snippet"; |
96 |
|
|
97 |
#ok($doc->scan_words(qw(this is demo)), "scan_words"); |
#ok($doc->scan_words(qw(this is demo)), "scan_words"); |
98 |
|
|
99 |
|
diag Dumper($doc); |