Fix deparsing of reversed foreach loops,
[p5sagit/p5-mst-13.2.git] / ext / B / t / f_sort.t
index 5a0c55b..7d60173 100644 (file)
@@ -3,18 +3,43 @@
 BEGIN {
     chdir q(t);
     @INC = qw(../lib ../ext/B/t);
+    require Config;
+    if (($Config::Config{'extensions'} !~ /\bB\b/) ){
+        print "1..0 # Skip -- Perl configured without B module\n";
+        exit 0;
+    }
+    if (!$Config::Config{useperlio}) {
+        print "1..0 # Skip -- need perlio to walk the optree\n";
+        exit 0;
+    }
+    if ($Config::Config{'extensions'} !~ /\bData\/Dumper\b/) {
+       print
+           "1..0 # Skip: Data::Dumper was not built, needed by OptreeCheck\n";
+       exit 0;
+    }
+    if ($] < 5.009) {
+        print "1..0 # Skip -- TODO - provide golden result regexps for 5.8\n";
+        exit 0;
+    }
     require q(./test.pl);
 }
 use OptreeCheck;
 plan tests => 20;
 
 
-=for gentest
+=head1 Test Notes
 
 # chunk: #!perl
 #examples poached from perldoc -f sort
 
-=cut
+NOTE: name is no longer a required arg for checkOptree, as label is
+synthesized out of others.  HOWEVER, if the test-code has newlines in
+it, the label must be overridden by an explicit name.
+
+This is because t/TEST is quite particular about the test output it
+processes, and multi-line labels violate its 1-line-per-test
+expectations.
+
 =for gentest
 
 # chunk: # sort lexically
@@ -142,7 +167,7 @@ checkOptree(note   => q{},
 # 3  <0> pushmark s
 # 4  <#> gv[*files] s
 # 5  <1> rv2av[t7] lK/1
-# 6  <@> sort lK/REV
+# 6  <@> sort lK/DESC
 # 7  <0> pushmark s
 # 8  <#> gv[*articles] s
 # 9  <1> rv2av[t2] lKRM*/1
@@ -154,7 +179,7 @@ EOT_EOT
 # 3  <0> pushmark s
 # 4  <$> gv(*files) s
 # 5  <1> rv2av[t3] lK/1
-# 6  <@> sort lK/REV
+# 6  <@> sort lK/DESC
 # 7  <0> pushmark s
 # 8  <$> gv(*articles) s
 # 9  <1> rv2av[t1] lKRM*/1
@@ -216,7 +241,7 @@ checkOptree(note   => q{},
 # 3  <0> pushmark s
 # 4  <#> gv[*files] s
 # 5  <1> rv2av[t7] lK/1
-# 6  <@> sort lK/REV,NUM
+# 6  <@> sort lK/DESC,NUM
 # 7  <0> pushmark s
 # 8  <#> gv[*articles] s
 # 9  <1> rv2av[t2] lKRM*/1
@@ -228,7 +253,7 @@ EOT_EOT
 # 3  <0> pushmark s
 # 4  <$> gv(*files) s
 # 5  <1> rv2av[t3] lK/1
-# 6  <@> sort lK/REV,NUM
+# 6  <@> sort lK/DESC,NUM
 # 7  <0> pushmark s
 # 8  <$> gv(*articles) s
 # 9  <1> rv2av[t1] lKRM*/1
@@ -333,9 +358,8 @@ print sort @george, 'to', @harry;
 
 =cut
 
-checkOptree(note   => q{},
+checkOptree(name   => q{sort USERSUB LIST },
            bcopts => q{-exec},
-           todo   => 'sort why BARE flag happens',     
            code   => q{sub backwards { $b cmp $a }
                        @harry = qw(dog cat x Cain Abel);
                        @george = qw(gone chased yz Punished Axed);
@@ -463,7 +487,7 @@ sort { $b->[1] <=> $a->[1]
 
 =cut
 
-checkOptree(note   => q{},
+checkOptree(name   => q{Compound sort/map Expression },
            bcopts => q{-exec},
            code   => q{ @new = map { $_->[0] }
                         sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] }
@@ -554,7 +578,7 @@ package main;
 
 =cut
 
-checkOptree(note   => q{},
+checkOptree(name   => q{sort other::sub LIST },
            bcopts => q{-exec},
            code   => q{package other; sub backwards ($$) { $_[1] cmp $_[0]; }
                        package main; @new = sort other::backwards @old; },