--- trunk/t/1_document.t 2006/01/04 15:04:58 8 +++ trunk/t/1_document.t 2006/01/04 15:28:39 9 @@ -3,7 +3,8 @@ use strict; use blib; -use Test::More tests => 25; +use Test::More tests => 27; +use Test::Exception; BEGIN { use_ok('Search::Estraier') }; @@ -19,6 +20,8 @@ ok(my $doc = new Search::Estraier::Document, 'new'); +isa_ok($doc, 'Search::Estraier::Document'); + cmp_ok($doc->id, '==', -1, 'id'); ok($doc->delete, "delete"); @@ -34,17 +37,20 @@ ok($doc->add_text('This is a demo'), 'add_text'); ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text'); +throws_ok { my $text = $doc->texts } qr/return array/, 'texts scalar'; +ok(my @texts = $doc->texts, 'texts array'); + ok(my $draft = $doc->dump_draft, 'dump_draft'); diag "dump_draft:\n$draft"; -ok(my $doc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft'); -cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same'); +#ok(my $doc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft'); +#cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same'); cmp_ok($doc->id, '==', -1, 'id'); -cmp_ok($doc2->id, '==', -1, 'id'); +#cmp_ok($doc2->id, '==', -1, 'id'); -my @attr = $doc->attr_names; +ok(my @attr = $doc->attr_names, 'attr_names'); diag "attr_names: ", join(',',@attr), "\n"; cmp_ok(scalar @attr, '==', 2, 'attr_names'); @@ -53,13 +59,13 @@ foreach my $a (keys %{$attr_data}) { cmp_ok($attr_data->{$a}, 'eq', $doc->attr($a), "attr $a = ".$attr_data->{$a}); - ok($doc->add_attr($a, ''), "delete attribute"); + ok($doc->add_attr($a, undef), "delete attribute"); } +@attr = $doc->attr_names, 'attr_names'; #diag "attr_names left: ", join(',',$doc->attr_names), "\n"; -cmp_ok($doc->attr_names, '==' , 0, "attributes removed"); +cmp_ok(@attr, '==' , 0, "attributes removed"); -my @texts = $doc->texts; diag "texts: ", join(',',@texts), "\n"; cmp_ok(scalar @texts, '==', 1, 'texts'); @@ -74,7 +80,7 @@ } -ok(my $snippet = $doc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet"); -diag "make_snippet:\n$snippet"; +#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"); +#ok($doc->scan_words(qw(this is demo)), "scan_words");