#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
#use FileHandle;
#use IPC::Open2;
# colours for output
our $norm = "[0m";
#our $bold = "[1;10m";
our $green = "[1;32m";
our $red = "[1;31m";
#our $yellow = "[1;33m";
our $tests = 0;
our $test_input;
our $expected_result;
while (<>) {
if (/^TEST:(.*)/) {
$test_input = $1;
$tests++;
}
if (/^RESULT:(.*)/) {
$expected_result = $1;
# strip begining whitespace
$expected_result =~ s/^\s+//;
# strip trailing whitespace
$expected_result =~ s/\s+$//;
if ($expected_result eq "success") {
open (TYPECHECK, "| ../range_checking_test");
print TYPECHECK $test_input;
} elsif ($expected_result eq "error") {
open (TYPECHECK, "| ../range_checking_test -r");
print TYPECHECK $test_input;
} else {
print "Unknown expected result: \"$expected_result\"\n";
next;
}
my $result = close (TYPECHECK);
if (! $result) {
print "\t[${red}FAILURE${norm}] in test $tests : $test_input\n";
exit(1);
}
}
}
print "\t\t\t\t\t[${green}SUCCESS${norm}]\n";
syntax highlighted by Code2HTML, v. 0.9.1