This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH warnings, perldiag] document diagnostics
[perl5.git] / t / lib / filter-util.pl
1
2 use strict ;
3 use warnings;
4
5 use vars qw( $Perl $Inc);
6
7 sub readFile
8 {
9     my ($filename) = @_ ;
10     my ($string) = '' ;
11
12     open (F, "<$filename") 
13         or die "Cannot open $filename: $!\n" ;
14     while (<F>)
15       { $string .= $_ }
16     close F ;
17     $string ;
18 }
19
20 sub writeFile
21 {
22     my($filename, @strings) = @_ ;
23     open (F, ">$filename") 
24         or die "Cannot open $filename: $!\n" ;
25     binmode(F) if $filename =~ /bin$/i;
26     foreach (@strings)
27       { print F }
28     close F or die "Could not close: $!" ;
29 }
30
31 sub ok
32 {
33     my($number, $result, $note) = @_ ;
34  
35     $note = "" if ! defined $note ;
36     if ($note) {
37         $note = "# $note" if $note !~ /^\s*#/ ;
38         $note =~ s/^\s*/ / ;
39     }
40
41     print "not " if !$result ;
42     print "ok ${number}${note}\n";
43 }
44
45 $Inc = '' ;
46 foreach (@INC)
47  { $Inc .= "\"-I$_\" " }
48
49 $Perl = '' ;
50 $Perl = ($ENV{'FULLPERL'} or $^X or 'perl') ;
51
52 $Perl = "$Perl -MMac::err=unix" if $^O eq 'MacOS';
53 $Perl = "$Perl -w" ;
54
55 1;