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

$NOTOK=0;

END {
  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) {
        $NOTOK++;
        $last_report = $.;
      } else {
        #      print "ok $.\n";
      }
    }
  } continue {
    print STDERR "\r$0: $." if $. % 100 == 0;
  }
  print "***FAILURES $NOTOK\n";
  $? = $NOTOK ? 99 : 0;
  print STDERR "\n";
}

1;
