43.2 Write TestSuite

563write TestSuite to stdout 563  (559)
print "-- Generated via\n-- ".join(" \\\n--   ", $0, @ARGV)."\n";
print <<’ALDORCODE’;
#include "testcases"
macro ADDTC(N, F) == l := append!(l, generateNamedTest(N, F));
macro NTC(N, F) == generateNamedTestCase(N, F);
TestSuite: with {
ALDORCODE

#what functions does the testsuite export...
#there is one function per test case domain
for $f (keys %DATA) {
    print "  runTestCase$DATA{$f}{’domain’}: () -> Integer;\n"
}

print <<’ALDORCODE’;
} == add {
ALDORCODE

#implement the function that are exported
my($file);
for $file (keys %DATA) {
    my($d) = $DATA{$file}{’domain’};
    print <<ALDORCODE;
  runTestCase$d(): Integer == {
    import from $d;
    import from TestSuiteTools;
    local l: List NamedTest := [];
ALDORCODE

#the function of one test case consists of several functions.
    for $f (@{$DATA{$file}{’lines’}}) {
        if ($f =~ /^#/) {print "$f\n"; next}
        $f =~ /^(test.*): \(\)->\(\);/;
        print "    ADDTC(\"$1\", $1);\n";
    }


    print <<ALDORCODE;
    processTestCase(\"$d\", setUp, l, tearDown);
  }
ALDORCODE
} # end for $file (keys %DATA)

print <<ALDORCODE;
}
import from TestSuite;
import from TestSuiteTools;
import from NamedTestCase;
import from List NamedTestCase;

ALDORCODE

print "runTestSuite(\"TestSuite\", \"$PROJECTNAME\", [\n";

my(@testcases)=();
for $f (keys %DATA) {
    my($d)=$DATA{$f}{’domain’};
    push @testcases,
      "NTC(\"$d\" , runTestCase$d)";
}
print "  ", join(",\n  ", @testcases), "\n";

print <<ALDORCODE;
]);
ALDORCODE

Uses PROJECTNAME 124 and test 353.