Change 34291 by [EMAIL PROTECTED] on 2008/09/06 06:54:40

        Integrate:
        [ 34255]
        Integrate:
        [ 34121]
        Start converting t/op/write.t to test.pl
        
        [ 34122]
        Reduce the -| skip back to just the tests that use it, and re-align the
        comments with the test code they refer to.
        
        [ 34123]
        Complete the conversion of t/op/write.t to test.pl, and remove my
        (accidentally committed) skip testing '1'.
        
        [ 34124]
        Bring the joy of strict to the rest of write.t
        
        [ 34157]
        Convert wantarray.t to use strict and test.pl
        
        [ 34172]
        Bring the joy of strict to t/harness.
        
        [ 34183]
        Use test.pl, not Test.pm, in t/run/*.t
        
        [ 34204]
        Skip the Perl debugger test if the harness itself is already running
        under some kind of debugger (such as a profiler) to avoid confusing
        things. (such as trashing the profiler output file from the harness.)

Affected files ...

... //depot/maint-5.8/perl/lib/perl5db.t#4 integrate
... //depot/maint-5.8/perl/t/harness#11 integrate
... //depot/maint-5.8/perl/t/op/wantarray.t#3 integrate
... //depot/maint-5.8/perl/t/op/write.t#14 integrate
... //depot/maint-5.8/perl/t/run/runenv.t#7 integrate

Differences ...

==== //depot/maint-5.8/perl/lib/perl5db.t#4 (text) ====
Index: perl/lib/perl5db.t
--- perl/lib/perl5db.t#3~32379~ 2007-11-17 12:42:55.000000000 -0800
+++ perl/lib/perl5db.t  2008-09-05 23:54:40.000000000 -0700
@@ -18,6 +18,10 @@
        print "1..0 # Skip: no /dev/tty\n";
        exit 0;
     }
+    if ($ENV{PERL5DB}) {
+       print "1..0 # Skip: \$ENV{PERL5DB} is already set to '$ENV{PERL5DB}'\n";
+       exit 0;
+    }
 }
 
 plan(1);

==== //depot/maint-5.8/perl/t/harness#11 (text) ====
Index: perl/t/harness
--- perl/t/harness#10~34290~    2008-09-05 23:35:49.000000000 -0700
+++ perl/t/harness      2008-09-05 23:54:40.000000000 -0700
@@ -12,6 +12,7 @@
 my $torture; # torture testing?
 
 use Test::Harness;
+use strict;
 
 $Test::Harness::switches = "";    # Too much noise otherwise
 $Test::Harness::Verbose++ while @ARGV && $ARGV[0] eq '-v' && shift;
@@ -26,7 +27,7 @@
 $ENV{PERL_CORE} = 1;
 
 #fudge DATA for now.
-%datahandle = qw(
+my %datahandle = qw(
                lib/bigint.t            1
                lib/bigintpm.t          1
                lib/bigfloat.t          1
@@ -45,7 +46,7 @@
      unlink "$_.t";
 }
 
-my @tests = ();
+my (@tests, $re);
 
 # [.VMS]TEST.COM calls harness with empty arguments, so clean-up @ARGV
 @ARGV = grep $_ && length( $_ ) => @ARGV;

==== //depot/maint-5.8/perl/t/op/wantarray.t#3 (xtext) ====
Index: perl/t/op/wantarray.t
--- perl/t/op/wantarray.t#2~22678~      2004-04-08 08:19:46.000000000 -0700
+++ perl/t/op/wantarray.t       2008-09-05 23:54:40.000000000 -0700
@@ -1,22 +1,29 @@
 #!./perl
 
-print "1..12\n";
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+    require './test.pl';
+}
+
+use strict;
+
+plan 13;
+
 sub context {
+  local $::Level = $::Level + 1;
   my ( $cona, $testnum ) = @_;
   my $conb = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V';
-  unless ( $cona eq $conb ) {
-       print "# Context $conb should be $cona\nnot ";
-  }
-  print "ok $testnum\n";
+  is $cona, $conb;
 }
 
-context('V',1);
-$a = context('S',2);
[EMAIL PROTECTED] = context('A',3);
-scalar context('S',4);
-$a = scalar context('S',5);
-($a) = context('A',6);
-($a) = scalar context('S',7);
+context('V');
+my $a = context('S');
+my @a = context('A');
+scalar context('S');
+$a = scalar context('S');
+($a) = context('A');
+($a) = scalar context('S');
 
 {
   # [ID 20020626.011] incorrect wantarray optimisation
@@ -27,18 +34,21 @@
   }
   my @b = inline();
   my $c = inline();
-  print +(@b == 1 && "@b" eq "2") ? "ok 8\n" : "not ok 8\t# <@b>\n";
-  print +($c == 2) ? "ok 9\n" : "not ok 9\t# <$c>\n";
+  is @b, 1;
+  is "@b", "2";
+  is $c, 2;
 }
 
+my $q;
+
 my $qcontext = q{
   $q = (defined wantarray) ? ( wantarray ? 'A' : 'S' ) : 'V';
 };
 eval $qcontext;
-print $q eq 'V' ? "ok 10\n" : "not ok 10\n";
+is $q, 'V';
 $a = eval $qcontext;
-print $q eq 'S' ? "ok 11\n" : "not ok 11\n";
+is $q, 'S';
 @a = eval $qcontext;
-print $q eq 'A' ? "ok 12\n" : "not ok 12\n";
+is $q, 'A';
 
 1;

==== //depot/maint-5.8/perl/t/op/write.t#14 (xtext) ====
Index: perl/t/op/write.t
--- perl/t/op/write.t#13~30498~ 2007-03-07 09:01:50.000000000 -0800
+++ perl/t/op/write.t   2008-09-05 23:54:40.000000000 -0700
@@ -3,8 +3,11 @@
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
+    require './test.pl';
 }
 
+use strict;    # Amazed that this hackery can be made strict ...
+
 # read in a file
 sub cat {
     my $file = shift;
@@ -58,14 +61,21 @@
 my $bas_tests = 20;
 
 # number of tests in section 3
-my $hmb_tests = 39;
+my $bug_tests = 4;
+
+# number of tests in section 4
+my $hmb_tests = 35;
 
-printf "1..%d\n", $bas_tests + $num_tests + $hmb_tests;
+my $tests = $bas_tests + $num_tests + $bug_tests + $hmb_tests;
+
+plan $tests;
 
 ############
 ## Section 1
 ############
 
+use vars qw($fox $multiline $foo $good);
+
 format OUT =
 the quick brown @<<
 $fox
@@ -94,7 +104,7 @@
 write(OUT);
 close OUT or die "Could not close: $!";
 
-$right =
+my $right =
 "the quick brown fox
 jumped
 forescore
@@ -105,10 +115,7 @@
 of huma...
 now is the time for all good men to come to\n";
 
-if (cat('Op_write.tmp') eq $right)
-    { print "ok 1\n"; 1 while unlink 'Op_write.tmp'; }
-else
-    { print "not ok 1\n"; }
+is cat('Op_write.tmp'), $right and do { 1 while unlink 'Op_write.tmp'; };
 
 $fox = 'wolfishness';
 my $fox = 'foxiness';          # Test a lexical variable.
@@ -147,10 +154,7 @@
 necessary
 now is the time for all good men to come to\n";
 
-if (cat('Op_write.tmp') eq $right)
-    { print "ok 2\n"; 1 while unlink 'Op_write.tmp'; }
-else
-    { print "not ok 2\n"; }
+is cat('Op_write.tmp'), $right and do { 1 while unlink 'Op_write.tmp'; };
 
 eval <<'EOFORMAT';
 format OUT2 =
@@ -191,14 +195,11 @@
 necessary
 now is the time for all good men to come to\n";
 
-if (cat('Op_write.tmp') eq $right)
-    { print "ok 3\n"; 1 while unlink 'Op_write.tmp'; }
-else
-    { print "not ok 3\n"; }
+is cat('Op_write.tmp'), $right and do { 1 while unlink 'Op_write.tmp' };
 
 # formline tests
 
-$mustbe = <<EOT;
+$right = <<EOT;
 @ a
 @> ab
 @>> abc
@@ -212,7 +213,8 @@
 @>>>>>>>>>>         abc
 EOT
 
-$was1 = $was2 = '';
+my $was1 = my $was2 = '';
+use vars '$format2';
 for (0..10) {           
   # lexical picture
   $^A = '';
@@ -225,8 +227,8 @@
   formline $format2, 'abc';
   $was2 .= "$format2 $^A\n";
 }
-print $was1 eq $mustbe ? "ok 4\n" : "not ok 4\n";
-print $was2 eq $mustbe ? "ok 5\n" : "not ok 5\n";
+is $was1, $right;
+is $was2, $right;
 
 $^A = '';
 
@@ -246,24 +248,24 @@
 $right =
 "fit\n";
 
-if (cat('Op_write.tmp') eq $right)
-    { print "ok 6\n"; 1 while unlink 'Op_write.tmp'; }
-else
-    { print "not ok 6\n"; }
+is cat('Op_write.tmp'), $right and do { 1 while unlink 'Op_write.tmp' };
+
 
 # test lexicals and globals
 {
+    my $test = curr_test();
     my $this = "ok";
-    our $that = 7;
+    our $that = $test;
     format LEX =
 @<<@|
 $this,$that
 .
     open(LEX, ">&STDOUT") or die;
     write LEX;
-    $that = 8;
+    $that = ++$test;
     write LEX;
     close LEX or die "Could not close: $!";
+    curr_test($test + 1);
 }
 # LEX_INTERPNORMAL test
 my %e = ( a => 1 );
@@ -274,13 +276,7 @@
 open   OUT4, ">Op_write.tmp" or die "Can't create Op_write.tmp";
 write (OUT4);
 close  OUT4 or die "Could not close: $!";
-if (cat('Op_write.tmp') eq "1\n") {
-    print "ok 9\n";
-    1 while unlink "Op_write.tmp";
-    }
-else {
-    print "not ok 9\n";
-    }
+is cat('Op_write.tmp'), "1\n" and do { 1 while unlink "Op_write.tmp" };
 
 eval <<'EOFORMAT';
 format OUT10 =
@@ -291,15 +287,13 @@
 
 open(OUT10, '>Op_write.tmp') || die "Can't create Op_write.tmp";
 
+use vars '$test1';
 $test1 = 12.95;
 write(OUT10);
 close OUT10 or die "Could not close: $!";
 
 $right = "   12.95 00012.95\n";
-if (cat('Op_write.tmp') eq $right)
-    { print "ok 10\n"; 1 while unlink 'Op_write.tmp'; }
-else
-    { print "not ok 10\n"; }
+is cat('Op_write.tmp'), $right and do { 1 while unlink 'Op_write.tmp' };
 
 eval <<'EOFORMAT';
 format OUT11 =
@@ -322,18 +316,16 @@
 "00012.95
 1 0#
 10 #\n";
-if (cat('Op_write.tmp') eq $right)
-    { print "ok 11\n"; 1 while unlink 'Op_write.tmp'; }
-else
-    { print "not ok 11\n"; }
+is cat('Op_write.tmp'), $right and do { 1 while unlink 'Op_write.tmp' };
 
 {
+    my $test = curr_test();
     our $el;
     format OUT12 =
 ok ^<<<<<<<<<<<<<<~~ # sv_chop() naze
 $el
 .
-    my %hash = (12 => 3);
+    my %hash = ($test => 3);
     open(OUT12, '>Op_write.tmp') || die "Can't create Op_write.tmp";
 
     for $el (keys %hash) {
@@ -341,15 +333,16 @@
     }
     close OUT12 or die "Could not close: $!";
     print cat('Op_write.tmp');
-
+    curr_test($test + 1);
 }
 
 {
+    my $test = curr_test();
     # Bug report and testcase by Alexey Tourbin
     use Tie::Scalar;
     my $v;
     tie $v, 'Tie::StdScalar';
-    $v = 13;
+    $v = $test;
     format OUT13 =
 ok ^<<<<<<<<< ~~
 $v
@@ -358,6 +351,7 @@
     write(OUT13);
     close OUT13 or die "Could not close: $!";
     print cat('Op_write.tmp');
+    curr_test($test + 1);
 }
 
 {   # test 14
@@ -365,9 +359,7 @@
     # must fail since we have a trailing ; in the eval'ed string (WL)
     my @v = ('k');
     eval "format OUT14 = [EMAIL PROTECTED]@v";
-    print +($@ && $@ =~ /Format not terminated/)
-      ? "ok 14\n" : "not ok 14 [EMAIL PROTECTED]";
-
+    like $@, qr/Format not terminated/;
 }
 
 {   # test 15
@@ -383,7 +375,7 @@
     write(OUT15);
     close OUT15 or die "Could not close: $!";
     my $res = cat('Op_write.tmp');
-    print $res eq "line 1\nline 2\n" ? "ok 15\n" : "not ok 15\n";
+    is $res, "line 1\nline 2\n";
 }
 
 {   # test 16: multiple use of a variable in same line with ^<
@@ -398,7 +390,7 @@
     write(OUT16);
     close OUT16 or die "Could not close: $!";
     my $res = cat('Op_write.tmp');
-    print $res eq <<EOD ? "ok 16\n" : "not ok 16\n";
+    is $res, <<EOD;
 this_is_block_1   this_is_block_2
 this_is_block_3   this_is_block_4
 EOD
@@ -420,7 +412,7 @@
     my $exp = <<EOD;
 Here we go: $txt That's all, folks!
 EOD
-    print $res eq $exp ? "ok 17\n" : "not ok 17\n";
+    is $res, $exp;
 }
 
 {   # test 18: @# and ~~ would cause runaway format, but we now
@@ -432,8 +424,7 @@
 .
     open(OUT18, '>Op_write.tmp') || die "Can't create Op_write.tmp";
     eval { write(OUT18); };
-    print +($@ && $@ =~ /Repeated format line will never terminate/)
-      ? "ok 18\n" : "not ok 18: [EMAIL PROTECTED]";
+    like $@,  qr/Repeated format line will never terminate/;
     close OUT18 or die "Could not close: $!";
 }
 
@@ -448,7 +439,7 @@
     write(OUT19);
     close OUT19 or die "Could not close: $!";
     my $res = cat('Op_write.tmp');
-    print $res eq <<EOD ? "ok 19\n" : "not ok 19\n";
+    is $res, <<EOD;
 gaga\0
 gaga\0
 EOD
@@ -477,7 +468,7 @@
     write(OUT20);
     close OUT20 or die "Could not close: $!";
     my $res = cat('Op_write.tmp');
-    print $res eq $exp ? "ok 20\n" : "not ok 20 res=[$res]exp=[$exp]\n";
+    is $res, $exp;
 }
 
 
@@ -486,68 +477,46 @@
 ## numeric formatting
 #####################
 
-my $nt = $bas_tests;
+curr_test($bas_tests + 1);
+
 for my $tref ( @NumTests ){
     my $writefmt = shift( @$tref );
     while (@$tref) {
        my $val      = shift @$tref;
        my $expected = shift @$tref;
         my $writeres = swrite( $writefmt, $val );
-        $nt++;
-       my $ok = ref($expected)
-                ? $writeres =~ $expected
-                : $writeres eq $expected;
-       
-        print $ok
-           ? "ok $nt - $writefmt\n"
-           : "not ok $nt\n# f=[$writefmt] exp=[$expected] got=[$writeres]\n";
+       if (ref $expected) {
+           like $writeres, $expected, $writefmt;
+       } else {
+           is $writeres, $expected, $writefmt;
+       }       
     }
 }
 
 
 #####################################
 ## Section 3
-## Easiest to add new tests above here
-#######################################
-
-# scary format testing from H.Merijn Brand
-
-my $test = $bas_tests + $num_tests + 1;
-my $tests = $bas_tests + $num_tests + $hmb_tests;
-
-if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' ||
-    ($^O eq 'os2' and not eval '$OS2::can_fork')) {
-  foreach ($test..$tests) {
-      print "ok $_ # skipped: '|-' and '-|' not supported\n";
-  }
-  exit(0);
-}
-
-
-use strict;    # Amazed that this hackery can be made strict ...
+## Easiest to add new tests just here
+#####################################
 
 # DAPM. Exercise a couple of error codepaths
 
 {
     local $~ = '';
     eval { write };
-    print "not " unless $@ and $@ =~ /Not a format reference/;
-    print "ok $test - Not a format reference\n";
-    $test++;
+    like $@, qr/Not a format reference/, 'format reference';
 
     $~ = "NOSUCHFORMAT";
     eval { write };
-    print "not " unless $@ and $@ =~ /Undefined format/;
-    print "ok $test - Undefined format\n";
-    $test++;
+    like $@, qr/Undefined format/, 'no such format';
 }
 
-# Just a complete test for format, including top-, left- and bottom marging
-# and format detection through glob entries
 
 format EMPTY =
 .
 
+my $test = curr_test();
+
 format Comment =
 ok @<<<<<
 $test
@@ -559,19 +528,39 @@
 open STDOUT_DUP, ">&STDOUT";
 my $oldfh = select STDOUT_DUP;
 $= = 10;
-{   local $~ = "Comment";
-    write;
-    $test++;
-    print $- == 9
-       ? "ok $test # TODO\n" : "not ok $test # TODO \$- = $- instead of 9\n";
-    $test++;
-    print $^ eq "STDOUT_DUP_TOP"
-       ? "ok $test\n" : "not ok $test\n# \$^ = $^ instead of 
'STDOUT_DUP_TOP'\n";
-    $test++;
+{
+  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;
 
+#############################
+## Section 4
+## Add new tests *above* here
+#############################
+
+# scary format testing from H.Merijn Brand
+
+# Just a complete test for format, including top-, left- and bottom marging
+# and format detection through glob entries
+
+if ($^O eq 'VMS' || $^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'MacOS' ||
+    ($^O eq 'os2' and not eval '$OS2::can_fork')) {
+  $test = curr_test();
+ SKIP: {
+      skip "'|-' and '-|' not supported", $tests - $test + 1;
+  }
+  exit(0);
+}
+
+
 $^  = "STDOUT_TOP";
 $=  =  7;              # Page length
 $-  =  0;              # Lines left
@@ -591,33 +580,31 @@
 
 my $opened = open FROM_CHILD, "-|";
 unless (defined $opened) {
-    print "not ok $test - open gave $!\n"; exit 0;
+    fail "open gave $!";
+    exit 0;
 }
 
 if ($opened) {
     # in parent here
 
-    print "ok $test - open\n"; $test++;
+    pass 'open';
     my $s = " " x $lm;
     while (<FROM_CHILD>) {
        unless (@data) {
-           print "not ok $test - too much output\n";
+           fail 'too much output';
            exit;
        }
        s/^/$s/;
        my $exp = shift @data;
-       print + ($_ eq $exp ? "" : "not "), "ok ", $test++, " \n";
-       if ($_ ne $exp) {
-           s/\n/\\n/g for $_, $exp;
-           print "#expected: $exp\n#got:      $_\n";
-       }
+       is $_, $exp;
     }
     close FROM_CHILD;
-    print + (@data?"not ":""), "ok ", $test++, " - too little output\n";
+    is "@data", "", "correct length of output";
     exit;
 }
 
 # in child here
+$::NO_ENDING = 1;
 
     select ((select (STDOUT), $| = 1)[0]);
 $tm = "\n" x $tm;

==== //depot/maint-5.8/perl/t/run/runenv.t#7 (text) ====
Index: perl/t/run/runenv.t
--- perl/t/run/runenv.t#6~26697~        2006-01-07 05:18:30.000000000 -0800
+++ perl/t/run/runenv.t 2008-09-05 23:54:40.000000000 -0700
@@ -12,10 +12,9 @@
         print "1..0 # Skip: no fork\n";
            exit 0;
     }
+    require './test.pl'
 }
 
-use Test;
-
 plan tests => 17;
 
 my $STDOUT = './results-0';
@@ -82,7 +81,8 @@
 sub try {
   my ($success, $reason) = runperl(@_);
   $reason =~ s/\n/\\n/g if defined $reason;
-  ok( !!$success, 1, $reason );
+  local $::Level = $::Level + 1;
+  ok( $success, $reason );
 }
 
 #  PERL5OPT    Command-line options (switches).  Switches in
End of Patch.

Reply via email to