1use strict; 2use warnings; 3 4my $true_ref; 5my $false_ref; 6BEGIN { 7 $true_ref = \!!1; 8 $false_ref = \!!0; 9} 10 11BEGIN { 12 unshift @INC, 't'; 13 unshift @INC, 't/compat' if $] < 5.006002; 14 require Config; 15 if ($ENV{PERL_CORE} and $Config::Config{'extensions'} !~ /\bStorable\b/) { 16 print "1..0 # Skip: Storable was not built\n"; 17 exit 0; 18 } 19} 20 21use Test::More tests => 12; 22use Storable qw(thaw freeze); 23 24use constant CORE_BOOLS => defined &builtin::is_bool; 25 26{ 27 my $x = $true_ref; 28 my $y = ${thaw freeze \$x}; 29 is($y, $x); 30 eval { 31 $$y = 2; 32 }; 33 isnt $@, '', 34 'immortal true maintained as immortal'; 35} 36 37{ 38 my $x = $false_ref; 39 my $y = ${thaw freeze \$x}; 40 is($y, $x); 41 eval { 42 $$y = 2; 43 }; 44 isnt $@, '', 45 'immortal false maintained as immortal'; 46} 47 48{ 49 my $true = $$true_ref; 50 my $x = \$true; 51 my $y = ${thaw freeze \$x}; 52 is($$y, $$x); 53 is($$y, '1'); 54 SKIP: { 55 skip "perl $] does not support tracking boolean values", 1 56 unless CORE_BOOLS; 57 BEGIN { CORE_BOOLS and warnings->unimport('experimental::builtin') } 58 ok builtin::is_bool($$y); 59 } 60 eval { 61 $$y = 2; 62 }; 63 is $@, '', 64 'mortal true maintained as mortal'; 65} 66 67{ 68 my $false = $$false_ref; 69 my $x = \$false; 70 my $y = ${thaw freeze \$x}; 71 is($$y, $$x); 72 is($$y, ''); 73 SKIP: { 74 skip "perl $] does not support tracking boolean values", 1 75 unless CORE_BOOLS; 76 BEGIN { CORE_BOOLS and warnings->unimport('experimental::builtin') } 77 ok builtin::is_bool($$y); 78 } 79 eval { 80 $$y = 2; 81 }; 82 is $@, '', 83 'mortal true maintained as mortal'; 84} 85