#!/usr/bin/perl -w

use CGI;
my $q = new CGI;

my @fail;
for ($x = 1; -f "test/fail/$x"; $x++) {
  push(@fail, $q->td({ -colspan => 2 }, [ $q->b(`grep "^$x:" test/test-cases.text | head -1`) ]));
  open(FILE, "test/fail/$x");
  @_ = <FILE>;
  push(@fail, $q->td([ $q->pre(join('', @_)), $q->font({ -face => 'courier' }, join('', `./algol60 < test/fail/$x 2>&1 > /dev/null`)) ]));
  close(FILE);
}

my @pass;
for ($x = 1; -d "test/pass/$x"; $x++) {
  push(@pass, $q->td({ -colspan => 2 }, [ $q->b(`grep "^$x:" test/test-cases.text | tail -1`) ]));
  open(FILE, "test/pass/$x/in");
  @_ = <FILE>;
  push(@pass, $q->td({ -valign => 'TOP' }, [ $q->pre(join('', @_)), $q->pre(join('', `./algol60 < test/pass/$x/in`)) ]));
  close(FILE);
}

print	$q->start_html( -title => "Corey and George's Test Plan", -text => 'black', -bgcolor => 'white' ),
	$q->table([
		$q->Tr([
			$q->td({-colspan =>2}, [ $q->h1("SAN474: Algol60 Compiler") ]),
			$q->td([ $q->h2('Fail tests') ]),
			@fail,
			$q->td([ $q->h2('Pass tests') ]),
			@pass
		])
	]),
	$q->end_html;
