develooper Front page | perl.perl5.porters | Postings from July 2008

formats, and write.t's sensitivity

Thread Next
From:
Nicholas Clark
Date:
July 11, 2008 14:32
Subject:
formats, and write.t's sensitivity
Message ID:
20080711213229.GF94237@plum.flirble.org
write.t ends with:

# scary format testing from H.Merijn Brand

and starts with a block of assignments that seem to be intended to (re)set all
state:

$^  = "STDOUT_TOP";
$=  =  7;		# Page length
$-  =  0;		# Lines left
my $ps = $^L; $^L = "";	# Catch the page separator
my $tm =  1;		# Top margin (empty lines before first output)
my $bm =  2;		# Bottom marging (empty lines between last text and footer)
my $lm =  4;		# Left margin (indent in spaces)


However, it doesn't seem to work perfectly (or there's something else daft
going on) because if I try to add just one wafer-thin formline ahead of it:

$ p4 diff
==== //depot/perl/t/op/write.t#50 - /afs/wu-wien.ac.at/home/ma/nclark/pecuchet/perl/t/op/write.t ====
--- /tmp/tmp.12618.0    2008-07-11 23:25:34.000000000 +0200
+++ /afs/wu-wien.ac.at/home/ma/nclark/pecuchet/perl/t/op/write.t        2008-07-11 23:24:04.000000000 +0200
@@ -581,6 +581,8 @@ if ($^O eq 'VMS' || $^O eq 'MSWin32' || 
   exit(0);
 }
 
+formline ".";
+$^A = '';
 
 $^  = "STDOUT_TOP";
 $=  =  7;              # Page length


then tests fail, starting like this:

ok 83 - open
ok 84
ok 85
ok 86
ok 87
ok 88
ok 89
ok 90
ok 91
ok 92
ok 93
ok 94
ok 95
ok 96
ok 97
ok 98
ok 99
ok 100
ok 101
ok 102
not ok 103
# Failed at t/op/write.t line 622
#      got '    ----
# '
# expected '    
# '
not ok 104
# Failed at t/op/write.t line 622
#      got '    
# '
# expected '    ----
# '
not ok 105
# Failed at t/op/write.t line 622
#      got '    1 1tseT
# '
# expected '    
# '
not ok 106
# Failed at t/op/write.t line 622
#      got '    2 2tseT
# '
# expected '    1 1tseT
# '
not ok 107



If one puts the formline above this block:

open STDOUT_DUP, ">&STDOUT";
my $oldfh = select STDOUT_DUP;
$= = 10;
{
  local $~ = "Comment";
  write;
  curr_test($test + 1);
  {
    local $::TODO = '[ID 20020227.005] format bug with undefined _TOP';
    is $-, 9;
  }
  is $^, "STDOUT_DUP_TOP";
}
select $oldfh;
close STDOUT_DUP;



then everything works. What's going on? What else does that block manage to
reset?

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About