#!/usr/local/bin/perl -w

use strict;

use Weekday qw(&day_of_week);

my @days = qw(sun mon tue wed thu fri sat);

my @tests = ([1969, 7, 20, "sun"],
	     [1997, 2, 23, "sun"],
	     [1998, 4, 17, "fri"],
	     [1999, 6, 9, "wed"],
	     [1999, 6, 10, "thu"]
	    );

my $n_errors = 0;

foreach my $test (@tests) {
  my ($year, $month, $date, $expected) = @$test;
  my $result = $days[day_of_week($year, $month, $date)];
  print "for $year-$month-$date, expected '$expected', got '$result'\n";

  ++ $n_errors unless $expected eq $result;
}

exit ($n_errors ? 1 : 0);
