# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

######################### We start with some black magic to print on failure.

# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)

use HTML::Index::Create;
use HTML::Index::Search;
use HTML::Index::Document;
use File::Path;

BEGIN { do 't/tests.pl'; }

@my_tests = (
    { q => 'some', paths => [ ] },
    { q => 'some AND NOT some', paths => [ ] },
    { q => 'some OR stuff', paths => [ 'eg/test1.html', 'eg/test2.html' ] },
    { q => 'some OR ( stuff AND NOT more )', paths => [ 'eg/test1.html', 'eg/test2.html' ] },
    { q => 'some OR ( stuff AND NOT sample )', paths => [ 'eg/test2.html' ] },
    { q => '( more OR stuff ) OR ( sample AND stuff )', paths => [ 'eg/test1.html', 'eg/test2.html' ] },
    { q => 'different', paths => [ 'eg/test3.html' ] },
);

my $indexer = HTML::Index::Create->new( 
    REFRESH => 1,
    STOP_WORD_FILE => 'eg/stopwords.txt',
) or die "Failed to create HTML::Index::Create object\n";
for ( @test_files )
{
    my $doc = HTML::Index::Document->new( path => $_ );
    $indexer->index_file( $doc );
}
undef $indexer;
my $searcher = HTML::Index::Search->new( 
    STOP_WORD_FILE => 'eg/stopwords.txt',
) or die "Failed to create HTML::Index::Search object\n";

print "1..", scalar( @my_tests ), "\n";
for my $test ( @my_tests )
{
    do_search_test( $searcher, $test );
}

######################### End of black magic.

# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
