From f864cbead6c53937ae2608099abd8c3d838de505 Mon Sep 17 00:00:00 2001 From: Zefram Date: Fri, 23 Aug 2013 22:58:41 +0100 Subject: [PATCH] regularise test for Carp vivifying B stash 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 | 21 +-------------------- dist/Carp/t/vivify_gv.t | 6 ++++-- dist/Carp/t/vivify_stash.t | 8 +++++--- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/dist/Carp/t/Carp.t b/dist/Carp/t/Carp.t index f513760..a569997 100644 --- a/dist/Carp/t/Carp.t +++ b/dist/Carp/t/Carp.t @@ -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] for 1..2; eval { croak 'heek' }; diff --git a/dist/Carp/t/vivify_gv.t b/dist/Carp/t/vivify_gv.t index 62602a4..6c76874 100644 --- a/dist/Carp/t/vivify_gv.t +++ b/dist/Carp/t/vivify_gv.t @@ -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; diff --git a/dist/Carp/t/vivify_stash.t b/dist/Carp/t/vivify_stash.t index 68dc9a7..536b35d 100644 --- a/dist/Carp/t/vivify_stash.t +++ b/dist/Carp/t/vivify_stash.t @@ -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; -- 2.7.4