#!/usr/bin/perl

# jan grant, 2002-04 (for the W3C)
# Quick and dirty, like all my Perl, with good reason:
# @{$$ isn't syntax, it's what I said when dealing with
# perl's notion of "data structures".
# XSLT would probably be simpler - but this can be used
# to drive scripts that run cases, rather than just
# outputting markup.

require "skeleton/readManifest.pl";

my $ALL;
my $fn = "testCaseTable.html";

if ($ARGV[0] eq "all") {
	$ALL = 1;
	$fn = "allTestCases.html";
} else {
	$ALL = 0;
}

print "Reading manifest file:\n";
my %tests = readManifest();
print "Done, there are ", scalar keys %tests, " tests defined\n";

sub foo($) {
	my ($uri) = @_;

	if ($uri =~ m|^http://www.w3.org/2000/10/rdf-tests/rdfcore/(.*)$|) {
		return $1;
	}
	return $uri;
}

print "These files are approved:\n";
foreach $testname ( keys %tests ) {
	my ($test) = $tests{$testname};
	next unless $$test{status} eq 'APPROVED';

	foreach $in (@{$$test{inputDocs}}) { print "APPROVED:: ", foo(${$in}{where}), "\n"; }
	exists $$test{inputDoc} and print "APPROVED:: ", foo(${$$test{inputDoc}}{where}), "\n";
	exists $$test{outputDoc} and print "APPROVED:: ", foo(${$$test{outputDoc}}{where}), "\n";
	foreach $in (@{$$test{premiseDocs}}) { print "APPROVED:: ", foo(${$in}{where}), "\n"; }
	exists $$test{conclusionDoc} and print "APPROVED:: ", foo(${$$test{conclusionDoc}}{where}), "\n";
	foreach $in (@{$$test{docs}}) { print "APPROVED:: ", foo(${$in}{where}), "\n"; }
}

print "These files are not approved:\n";
foreach $testname ( keys %tests ) {
	my ($test) = $tests{$testname};
	next unless $$test{status} ne 'APPROVED';

	foreach $in (@{$$test{inputDocs}}) { print "NOT_APPROVED:: ", foo(${$in}{where}), "\n"; }
	exists $$test{inputDoc} and print "NOT_APPROVED:: ", foo(${$$test{inputDoc}}{where}), "\n";
	exists $$test{outputDoc} and print "NOT_APPROVED:: ", foo(${$$test{outputDoc}}{where}), "\n";
	foreach $in (@{$$test{premiseDocs}}) { print "NOT_APPROVED:: ", foo(${$in}{where}), "\n"; }
	exists $$test{conclusionDoc} and print "NOT_APPROVED:: ", foo(${$$test{conclusionDoc}}{where}), "\n";
	foreach $in (@{$$test{docs}}) { print "NOT_APPROVED:: ", foo(${$in}{where}), "\n"; }
}

