Skip tests that require Data::Dumper if it is not built
[p5sagit/p5-mst-13.2.git] / ext / B / t / deparse.t
index a3c2bec..fed9cf0 100644 (file)
@@ -8,6 +8,11 @@ BEGIN {
        @INC = '.';
        push @INC, '../lib';
     }
+    require Config;
+    if (($Config::Config{'extensions'} !~ /\bB\b/) ){
+        print "1..0 # Skip -- Perl configured without B module\n";
+        exit 0;
+    }
 }
 
 $|  = 1;
@@ -15,7 +20,7 @@ use warnings;
 use strict;
 use Config;
 
-print "1..31\n";
+print "1..32\n";
 
 use B::Deparse;
 my $deparse = B::Deparse->new() or print "not ";
@@ -83,12 +88,11 @@ print "not " if "{\n    (-1) ** \$a;\n}"
                ne $deparse->coderef2text(sub{(-1) ** $a });
 print "ok " . $i++ . "\n";
 
-# XXX ToDo - constsub that returns a reference
-#use constant cr => ['hello'];
-#my $string = "sub " . $deparse->coderef2text(\&cr);
-#my $val = (eval $string)->();
-#print "not " if ref($val) ne 'ARRAY' || $val->[0] ne 'hello';
-#print "ok " . $i++ . "\n";
+use constant cr => ['hello'];
+my $string = "sub " . $deparse->coderef2text(\&cr);
+my $val = (eval $string)->();
+print "not " if ref($val) ne 'ARRAY' || $val->[0] ne 'hello';
+print "ok " . $i++ . "\n";
 
 my $a;
 my $Is_VMS = $^O eq 'VMS';
@@ -208,9 +212,7 @@ my ($x,@a);
 $x=1 for @a;
 >>>>
 my($x, @a);
-foreach $_ (@a) {
-    $x = 1;
-}
+$x = 1 foreach (@a);
 ####
 # 19
 for (my $i = 0; $i < 2;) {