Re: [PATCH] Cleanup of the regexp API
[p5sagit/p5-mst-13.2.git] / ext / B / t / xref.t
index 8268e3f..450582b 100644 (file)
@@ -1,11 +1,22 @@
-#!./perl -w
+#!./perl
 
 BEGIN {
-    chdir 't' if -d 't';
-    @INC = qw(../lib);
+    if ($ENV{PERL_CORE}){
+       chdir('t') if -d 't';
+       @INC = ('.', '../lib');
+    } else {
+       unshift @INC, 't';
+    }
+    require Config;
+    if (($Config::Config{'extensions'} !~ /\bB\b/) ){
+        print "1..0 # Skip -- Perl configured without B module\n";
+        exit 0;
+    }
 }
 
 use strict;
+use warnings;
+no warnings 'once';
 use Test::More tests => 14;
 
 # line 50
@@ -13,12 +24,14 @@ use_ok( 'B::Xref' );
 
 my $file = 'xreftest.out';
 
+open SAVEOUT, ">&STDOUT" or diag $!;
+close STDOUT;
 # line 100
 our $compilesub = B::Xref::compile("-o$file");
 ok( ref $compilesub eq 'CODE', "compile() returns a coderef ($compilesub)" );
 $compilesub->(); # Compile this test script
-
-#END { unlink $file or diag "END block failed: $!" }
+close STDOUT;
+open STDOUT, ">&SAVEOUT" or diag $!;
 
 # Now parse the output
 # line 200
@@ -93,6 +106,10 @@ is(
     '1001', 'glob FOO used in subroutine foo'
 );
 
+END {
+    1 while unlink $file;
+}
+
 # End of tests.
 # Now some stuff to feed B::Xref
 
@@ -100,3 +117,4 @@ is(
 package Testing::Xref;
 sub foo { print FOO %::xreftable; }
 sub bar { print FOO foo; }
+