Change 14465 by jhi@alpha on 2002/01/28 13:36:15

        The "used only once" warnings (from gv_check) come
        in pseudorandom hash order-- in EBCDIC the order
        is different.  Add a new option that allow the warnings
        to come in any order (Paul Marquess).

Affected files ...

.... //depot/perl/lib/warnings.t#7 edit
.... //depot/perl/t/lib/warnings/perl#2 edit

Differences ...

==== //depot/perl/lib/warnings.t#7 (text) ====
Index: perl/lib/warnings.t
--- perl/lib/warnings.t.~1~     Mon Jan 28 06:45:05 2002
+++ perl/lib/warnings.t Mon Jan 28 06:45:05 2002
@@ -119,18 +119,29 @@
     my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
     # any special options? (OPTIONS foo bar zap)
     my $option_regex = 0;
+    my $option_random = 0;
     if ($expected =~ s/^OPTIONS? (.+)\n//) {
        foreach my $option (split(' ', $1)) {
            if ($option eq 'regex') { # allow regular expressions
                $option_regex = 1;
-           } else {
+           } 
+           elsif ($option eq 'random') { # all lines match, but in any order
+               $option_random = 1;
+           }
+           else {
                die "$0: Unknown OPTION '$option'\n";
            }
        }
     }
+    die "$0: can't have OPTION regex and random\n"
+        if $option_regex + option_random > 1;
     if ( $results =~ s/^SKIPPED\n//) {
        print "$results\n" ;
     }
+    elsif ($option_random)
+    {
+        print "not " if !randomMatch($results, $expected);
+    }
     elsif (($prefix  && (( $option_regex && $results !~ /^$expected/) ||
                         (!$option_regex && $results !~ /^\Q$expected/))) or
           (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
@@ -144,3 +155,15 @@
     foreach (@temps)
        { unlink $_ if $_ }
 }
+
+sub randomMatch
+{
+    my $got = shift ;
+    my $expected = shift;
+
+    my @got = sort split "\n", $got ;
+    my @expected = sort split "\n", $expected ;
+
+   return "@got" eq "@expected";
+
+}

==== //depot/perl/t/lib/warnings/perl#2 (text) ====
Index: perl/t/lib/warnings/perl
--- perl/t/lib/warnings/perl.~1~        Mon Jan 28 06:45:05 2002
+++ perl/t/lib/warnings/perl    Mon Jan 28 06:45:05 2002
@@ -46,6 +46,7 @@
 use warnings 'once' ;
 $z = 3 ;
 EXPECT
+OPTION random
 Name "main::z" used only once: possible typo at - line 6.
 Name "main::x" used only once: possible typo at - line 4.
 ########
End of Patch.

Reply via email to