xref: /openbsd/gnu/usr.bin/perl/cpan/Pod-Simple/t/tiedfh.t (revision 09467b48)
1# Testing tied output filehandle
2BEGIN {
3    if($ENV{PERL_CORE}) {
4        chdir 't';
5        @INC = '../lib';
6    }
7}
8
9use strict;
10use Test;
11BEGIN { plan tests => 8 };
12
13use Pod::Simple::TiedOutFH;
14ok 1;
15
16print "# Sanity test of Perl and Pod::Simple::TiedOutFH\n";
17
18{
19  my $x = 'abc';
20  my $out = Pod::Simple::TiedOutFH->handle_on($x);
21  print $out "Puppies\n";
22  print $out "rrrrr";
23  print $out "uffuff!";
24  ok $x, "abcPuppies\nrrrrruffuff!";
25  undef $out;
26  ok $x, "abcPuppies\nrrrrruffuff!";
27}
28
29# Now test that we can have two different strings.
30{
31  my $x1 = 'abc';
32  my $x2 = 'xyz';
33  my $out1 = Pod::Simple::TiedOutFH->handle_on($x1);
34  my $out2 = Pod::Simple::TiedOutFH->handle_on($x2);
35
36  print $out1 "Puppies\n";
37  print $out2 "Kitties\n";
38  print $out2 "mmmmm";
39  print $out1 "rrrrr";
40  print $out2 "iaooowwlllllllrrr!\n";
41  print $out1 "uffuff!";
42
43  ok $x1, "abcPuppies\nrrrrruffuff!",              "out1 test";
44  ok $x2, "xyzKitties\nmmmmmiaooowwlllllllrrr!\n", "out2 test";
45
46  undef $out1;
47  undef $out2;
48
49  ok $x1, "abcPuppies\nrrrrruffuff!",              "out1 test";
50  ok $x2, "xyzKitties\nmmmmmiaooowwlllllllrrr!\n", "out2 test";
51}
52
53
54print "# Wrapping up... one for the road...\n";
55ok 1;
56print "# --- Done with ", __FILE__, " --- \n";
57
58
59