1b39c5158Smillert# Testing tied output filehandle 2b39c5158Smillertuse strict; 3256a93a4Safresh1use warnings; 4*5486feefSafresh1use Test::More tests => 6; 5b39c5158Smillert 6b39c5158Smillertuse Pod::Simple::TiedOutFH; 7b39c5158Smillert 8b39c5158Smillertprint "# Sanity test of Perl and Pod::Simple::TiedOutFH\n"; 9b39c5158Smillert 10b39c5158Smillert{ 11b39c5158Smillert my $x = 'abc'; 12b39c5158Smillert my $out = Pod::Simple::TiedOutFH->handle_on($x); 13b39c5158Smillert print $out "Puppies\n"; 14b39c5158Smillert print $out "rrrrr"; 15b39c5158Smillert print $out "uffuff!"; 16*5486feefSafresh1 is $x, "abcPuppies\nrrrrruffuff!"; 17b39c5158Smillert undef $out; 18*5486feefSafresh1 is $x, "abcPuppies\nrrrrruffuff!"; 19b39c5158Smillert} 20b39c5158Smillert 21b39c5158Smillert# Now test that we can have two different strings. 22b39c5158Smillert{ 23b39c5158Smillert my $x1 = 'abc'; 24b39c5158Smillert my $x2 = 'xyz'; 25b39c5158Smillert my $out1 = Pod::Simple::TiedOutFH->handle_on($x1); 26b39c5158Smillert my $out2 = Pod::Simple::TiedOutFH->handle_on($x2); 27b39c5158Smillert 28b39c5158Smillert print $out1 "Puppies\n"; 29b39c5158Smillert print $out2 "Kitties\n"; 30b39c5158Smillert print $out2 "mmmmm"; 31b39c5158Smillert print $out1 "rrrrr"; 32b39c5158Smillert print $out2 "iaooowwlllllllrrr!\n"; 33b39c5158Smillert print $out1 "uffuff!"; 34b39c5158Smillert 35*5486feefSafresh1 is $x1, "abcPuppies\nrrrrruffuff!", "out1 test"; 36*5486feefSafresh1 is $x2, "xyzKitties\nmmmmmiaooowwlllllllrrr!\n", "out2 test"; 37b39c5158Smillert 38b39c5158Smillert undef $out1; 39b39c5158Smillert undef $out2; 40b39c5158Smillert 41*5486feefSafresh1 is $x1, "abcPuppies\nrrrrruffuff!", "out1 test"; 42*5486feefSafresh1 is $x2, "xyzKitties\nmmmmmiaooowwlllllllrrr!\n", "out2 test"; 43b39c5158Smillert} 44