File: order.t

package info (click to toggle)
libfilter-perl 1.64-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 668 kB
  • sloc: perl: 963; makefile: 10
file content (88 lines) | stat: -rw-r--r-- 1,550 bytes parent folder | download | duplicates (5)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! perl
# check that the filters are destroyed in the correct order by
# installing two different types of filter. If they don't get destroyed
# in the correct order we should get a "filter_del can only delete in
# reverse order" error

# skip this set of tests is running on anything less than 5.006
if ($] < 5.006) {
    print "1..0\n";
    exit 0;
}

use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin"; # required to load filter-util.pl

require "filter-util.pl" ;

use vars qw( $Inc $Perl) ;

my $file = "order.test" ;
my $module = "FilterTry";
my $tee1 = "order1" ;
$Inc .= " -It";

writeFile("t/${module}.pm", <<EOM, <<'EOM') ;
package ${module} ;

EOM
use Filter::Util::Call ;
sub import {
    filter_add(
        sub {

            my ($status) ;

            if (($status = filter_read()) > 0) {
                s/ABC/DEF/g
            }
            $status ;
        } ) ;
}

1;
__END__

=head1 NAME

FilterTry - Perl Source Filter Example Module created by t/order.t

=head1 SYNOPSIS

    use FilterTry ;
    sourcecode...

=cut
EOM

my $fil1 = <<"EOM";
use $module ;

print "ABC ABC\n" ;

EOM

writeFile($file, <<"EOM", $fil1) ;
use Filter::tee '>$tee1' ;
EOM

my $a = `$Perl $Inc $file 2>&1` ;

print "1..3\n" ;

ok(1, ($? >> 8) == 0) ;
chomp $a; 	# strip crlf resp. lf
#print "|$a|\n";
ok(2, $a eq "DEF DEF");

my $readtee1 = readFile($tee1);
if ($^O eq 'MSWin32') {
   $readtee1 =~ s/\r//g;
}
ok(3, $fil1 eq $readtee1) ;

unlink $file or die "Cannot remove $file: $!\n" ;
unlink $tee1 or die "Cannot remove $tee1: $!\n" ;