12 if ($v == $val) { $had = 1; }
13 else { push @hasnt, $v; }
15 return ($had, \
@hasnt);
18 # Setting $strict to 1 enables line number checks, setting it to 2 makes
19 # line number mismatches fatal.
24 print STDERR
"Usage: $0 testcase.cs testcase.out\n";
32 my $csfile = $ARGV [0];
33 my $mcsout = $ARGV [1];
38 open (INPUT
, "<$csfile") or die
39 "Can't open testcase: $!";
40 while (defined ($input = <INPUT
>)) {
43 next unless $input =~ m
,^\s
*//\s
*(error
|warning
)?\s
*(CS\d
+),;
45 if ((defined $1) and ($1 eq 'warning')) {
46 push @
{$warnings{$2}}, $line+1;
48 push @
{$errors{$2}}, $line+1;
56 open (MCS
, "$mcsout") or die
57 "Can't open compiler output file: $!";
59 while (defined ($input = <MCS
>)) {
61 next unless $input =~ m
,\
((\d
+)\
)\s
+(warning
|error
)\s
+(CS\d
+):,;
64 if ($2 eq 'warning') {
65 ($had, $warnings{$3}) = remove
$1, $warnings{$3};
66 if ($strict && ! $had) {
67 print "Didn't expect any warnings on line $1, but got $2 $3.\n";
68 $failures++ if $strict == 2;
71 ($had, $errors{$3}) = remove
$1, $errors{$3};
72 if ($strict && ! $had) {
73 print "Didn't expect any errors on line $1, but got $2 $3.\n";
74 $failures++ if $strict == 2;
78 print "Expected to find ".$lines{$1}." on line $1, but got $3.\n"
79 if $strict and $lines{$1} ne $3;
84 foreach my $error (keys %errors) {
85 print "Failed to report error $error on line $_\n"
86 for @
{$errors{$error}};
87 $failures += @
{$errors{$error}};
90 foreach my $warning (keys %warnings) {
91 print "Failed to report warning $warning on line $_\n"
92 for @
{$warnings{$warning}};
93 $failures += @
{$warnings{$warning}};
96 exit ($failures != 0);