This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regularise test for Carp vivifying B stash
authorZefram <zefram@fysh.org>
Fri, 23 Aug 2013 21:58:41 +0000 (22:58 +0100)
committerZefram <zefram@fysh.org>
Sat, 24 Aug 2013 01:17:44 +0000 (02:17 +0100)
There's an old test to check that Carp doesn't vivify B:: despite
attempting to use B::svref_2object().  Turn this into the same kind of
test now used for overload::StrVal() and utf8::downgrade(), testing more
cleanly for stash vivification and also testing for GV vivification.

dist/Carp/t/Carp.t
dist/Carp/t/vivify_gv.t
dist/Carp/t/vivify_stash.t

index f513760..a569997 100644 (file)
@@ -3,7 +3,7 @@ no warnings "once";
 use Config;
 
 use IPC::Open3 1.0103 qw(open3);
-use Test::More tests => 63;
+use Test::More tests => 62;
 
 sub runperl {
     my(%args) = @_;
@@ -419,25 +419,6 @@ SKIP:
     );
 }
 
-SKIP:
-{
-    skip "IPC::Open3::open3 needs porting", 1 if $Is_VMS;
-    skip("B:: always created when static", 1)
-      if $Config{static_ext} =~ /\bB\b/;
-    is(
-      runperl(
-       prog => q<
-         use Carp;
-         $SIG{__WARN__} = sub{};
-         carp (qq(A duck, but which duck?));
-         print q(ok) unless exists $::{q(B::)};
-       >,
-      ),
-      'ok',
-      'Carp does not autovivify *B::',
-    );
-}
-
 # [perl #96672]
 <D::DATA> for 1..2;
 eval { croak 'heek' };
index 62602a4..6c76874 100644 (file)
@@ -1,14 +1,16 @@
-BEGIN { print "1..3\n"; }
+BEGIN { print "1..4\n"; }
 
 our $has_is_utf8; BEGIN { $has_is_utf8 = exists($utf8::{"is_utf8"}); }
 our $has_dgrade; BEGIN { $has_dgrade = exists($utf8::{"downgrade"}); }
 our $has_strval; BEGIN { $has_strval = exists($overload::{"StrVal"}); }
+our $has_sv2obj; BEGIN { $has_sv2obj = exists($B::{"svref_2object"}); }
 
 use Carp;
 sub { Carp::longmess() }->(\1);
 
 print !(exists($utf8::{"is_utf8"}) xor $has_is_utf8) ? "" : "not ", "ok 1\n";
 print !(exists($utf8::{"downgrade"}) xor $has_dgrade) ? "" : "not ", "ok 2\n";
-print !(exists($overload::{"StrVal"}) xor $has_strval) ? "" : "not ", "ok 3\n";
+print !(exists($overload::{"StrVal"}) xor $has_sv2obj) ? "" : "not ", "ok 3\n";
+print !(exists($B::{"svref_2object"}) xor $has_sv2obj) ? "" : "not ", "ok 4\n";
 
 1;
index 68dc9a7..536b35d 100644 (file)
@@ -1,23 +1,25 @@
-BEGIN { print "1..4\n"; }
+BEGIN { print "1..5\n"; }
 
 our $has_utf8; BEGIN { $has_utf8 = exists($::{"utf8::"}); }
 our $has_overload; BEGIN { $has_overload = exists($::{"overload::"}); }
+our $has_B; BEGIN { $has_B = exists($::{"B::"}); }
 
 use Carp;
 sub { Carp::longmess() }->(\1);
 
 print !(exists($::{"utf8::"}) xor $has_utf8) ? "" : "not ", "ok 1\n";
 print !(exists($::{"overload::"}) xor $has_overload) ? "" : "not ", "ok 2\n";
+print !(exists($::{"B::"}) xor $has_B) ? "" : "not ", "ok 3\n";
 
 # Autovivify $::{"overload::"}
 () = \$::{"overload::"};
 () = \$::{"utf8::"};
 eval { sub { Carp::longmess() }->(\1) };
-print $@ eq '' ? "ok 3\n" : "not ok 3\n# $@";
+print $@ eq '' ? "ok 4\n" : "not ok 4\n# $@";
 
 # overload:: glob without hash
 undef *{"overload::"};
 eval { sub { Carp::longmess() }->(\1) };
-print $@ eq '' ? "ok 4\n" : "not ok 4\n# $@";
+print $@ eq '' ? "ok 5\n" : "not ok 5\n# $@";
 
 1;