
package Scoretest;
my $testfile = $ENV{ANAGRAM_SCORES} || 'words.as';
my $last_report = 0;

END {
  print "1..1\n";
  my $start = time;
  open F, "<", $testfile or die $!;
  while (<F>) {
    chomp;
    my ($s, @w) = split;
    for (\@w, [reverse @w]) {
      my ($w1, $w2) = @$_;
      my $as = main::min_chunks($w1, $w2);
      if ($as != $s) {
        print "not ok $. # ($w1, $w2) was $as, should be  $s\n";
        $NOTOK++;
        $last_report = $.;
      } else {
        #      print "ok $.\n";
      }
    }
  } continue {
    if ($. - $last_report >= 100) {
      my $elapsed = time - $start;
      print STDERR "$. words checked ($elapsed sec).\n";
      $last_report = $.;
    }
  }
  if ($NOTOK) {
    print STDERR "not ok # $NOTOK failures?\n";
  } else {
    print STDERR "ok\n";
  }
}

1;
