File: Checker.pm

package info (click to toggle)
libconvert-binhex-perl 1.119%2Bpristine-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 312 kB
  • ctags: 137
  • sloc: perl: 838; makefile: 45
file content (33 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Checker;

@ISA = qw(Exporter);
@EXPORT = qw($CHECK okay_if note check filter_warnings);

$Checker::OUTPUT = 1;
$Checker::CHECK  = 0;

# Only lets through warnings that originate outside our toolkit:
sub filter_warnings {
    $SIG{'__WARN__'} = sub { 
	print STDERR $_[0] if ($_[0] !~ /^MIME:/);
    };
}

sub okay_if { 
    print( ($_[0] ? "ok\n" : "not ok\n")) 
}

sub note    { 
    print STDOUT "        ## ", @_, "\n" if $OUTPUT;
}

sub check   { 
    ++$CHECK;
    my ($ok, $note) = @_;
    $note = ($note ? ": $note" : '');
    my $stat = ($ok ? 'OK ' : 'ERR');
    printf STDOUT "        Test %2d$note\n", $CHECK  if $OUTPUT;
    print(($ok ? "ok $CHECK\n" : "not ok $CHECK\n"));
}
1;