# -*- perl -*-

# 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.)

BEGIN { $| = 1; print "1..6\n"; }
END {print "not ok 1\n" unless $loaded;}
use Align::NW;
$loaded = 1;
print "ok 1\n";

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

my $N = 2;
sub Not { print "not " }
sub OK  { print "ok ", $N++, "\n" }


my $Test2 = { a     => 'abcde',
	      b     => 'abcde',
	      score => 5,
	      align => { a => 'abcde',
			 s => '|||||',
			 b => 'abcde' } };

my $Test3 = { a     => 'abcdefgh',
	      b     => 'abcxefgh',
	      score => 6,
	      align => { a => 'abcdefgh',
			 s => '||| ||||',
			 b => 'abcxefgh' } };

my $Test4 = { a     => 'abcdefgh',
	      b     => 'bcdefghi',
	      score => 7,
	      align => { a => 'abcdefgh',
			 s => ' |||||||',
			 b => ' bcdefghi' } };

my $Test5 = { a     => 'abcdefghijklmnopqrst',
	      b     => 'abcdijklqrst',
	      score => 2,
	      align => { a => 'abcdefghijklmnopqrst',
			 s => '||||    ||||    ||||',
			 b => 'abcd....ijkl....qrst' } };


my $Test6 = { a     => 'cgatcaaacaaccgat',
	      b     => 'cgatcaaccgat',
	      score => 8,
	      align => { a => 'cgatcaaacaaccgat',
			 s => '    | | ||||||||',
			 b => '    cgatcaaccgat' } };

my @Tests = ($Test2, $Test3, $Test4, $Test5, $Test6);

my $Payoff = { match      =>  1,
	       mismatch   => -1,
	       gap_open   => -1,
	       gap_extend => -1 };


for my $test (@Tests)
{
    my $nw = new Align::NW $test->{a}, $test->{b}, $Payoff;

    $nw->score;
    $nw->align;

    my $score = $nw->get_score;
    my $align = $nw->get_align;

    $score      == $test->{score}    and
    $align->{a} eq $test->{align}{a} and 
    $align->{s} eq $test->{align}{s} and 
    $align->{b} eq $test->{align}{b} or  Not; OK;
}




