3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 33; |
use Test::More tests => 37; |
7 |
use Test::Exception; |
use Test::Exception; |
8 |
use Data::Dumper; |
use Data::Dumper; |
9 |
|
|
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'; |
ok(my @texts = $doc->texts, 'texts'); |
|
ok(my @texts = $doc->texts, 'texts array'); |
|
51 |
|
|
52 |
ok(my $draft = $doc->dump_draft, 'dump_draft'); |
ok(my $draft = $doc->dump_draft, 'dump_draft'); |
53 |
|
|
54 |
diag "dump_draft:\n$draft"; |
#diag "dump_draft:\n$draft"; |
55 |
|
|
56 |
ok(my $doc2 = new Search::Estraier::Document($draft), 'new from draft'); |
ok(my $doc2 = new Search::Estraier::Document($draft), 'new from draft'); |
57 |
cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same'); |
cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same'); |
60 |
cmp_ok($doc2->id, '==', -1, 'id'); |
cmp_ok($doc2->id, '==', -1, 'id'); |
61 |
|
|
62 |
ok(my @attr = $doc->attr_names, 'attr_names'); |
ok(my @attr = $doc->attr_names, 'attr_names'); |
63 |
diag "attr_names: ", join(',',@attr), "\n"; |
#diag "attr_names: ", join(',',@attr), "\n"; |
64 |
|
|
65 |
cmp_ok(scalar @attr, '==', 2, 'attr_names'); |
cmp_ok(scalar @attr, '==', 2, 'attr_names'); |
66 |
|
|
75 |
#diag "attr_names left: ", join(',',$doc->attr_names), "\n"; |
#diag "attr_names left: ", join(',',$doc->attr_names), "\n"; |
76 |
cmp_ok(@attr, '==' , 0, "attributes removed"); |
cmp_ok(@attr, '==' , 0, "attributes removed"); |
77 |
|
|
78 |
diag "texts: ", join(',',@texts), "\n"; |
#diag "texts: ", join(',',@texts), "\n"; |
79 |
ok(eq_array(\@test_texts, \@texts), 'texts'); |
ok(eq_array(\@test_texts, \@texts), 'texts'); |
80 |
|
|
81 |
ok(my $cat_text = $doc->cat_texts, 'cat_text'); |
ok(my $cat_text = $doc->cat_texts, 'cat_text'); |
82 |
diag "cat_texts: $cat_text"; |
#diag "cat_texts: $cat_text"; |
83 |
|
|
84 |
|
ok($doc = new Search::Estraier::Document, 'new empty'); |
85 |
SKIP: { |
ok(! $doc->texts, 'texts'); |
86 |
skip "est_keywords not implemented", 2; |
cmp_ok($doc->dump_draft, 'eq', "\n", 'dump_draft'); |
87 |
|
cmp_ok($doc->id, '==', -1, 'id'); |
88 |
my @keywords = $doc->keywords; |
ok(! $doc->attr_names, 'attr_names'); |
89 |
diag "keywords: ", join(',',@keywords), "\n"; |
ok(! $doc->attr(undef), 'attr'); |
90 |
|
ok(! $doc->cat_texts, 'cat_texts'); |
|
cmp_ok(scalar @keywords, '==', 1, 'keywords'); |
|
|
} |
|
|
|
|
|
|
|
|
#ok(my $snippet = $doc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet"); |
|
|
#diag "make_snippet:\n$snippet"; |
|
|
|
|
|
#ok($doc->scan_words(qw(this is demo)), "scan_words"); |
|
91 |
|
|
92 |
#diag Dumper($doc); |
#diag Dumper($doc); |