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
# 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
# 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
# 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
# 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
=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);
=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] }
=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; },