From 50621bf1d40510490a77db174fbc16c1fbfb8aea Mon Sep 17 00:00:00 2001 From: Zefram Date: Fri, 21 Jul 2017 08:50:12 +0100 Subject: [PATCH] fix Storable test for pre-5.19.2 threaded perls The test of Storable's identity-preserving handling of the immortal scalars ran into trouble with an old bug regarding overloading of the PADTMP flag, which could prevent the test script getting actual references to the immortal truth values in order to feed to Storable and to compare its output against. On the affected perls, compiling code that includes a const op whose value is an immortal makes subsequent executions of the refgen operator on that immortal scalar copy it, breaking its identity. Loading the testing infrastructure modules could easily perform such compilation, though whether it actually does depends on the versions of the modules. Work around this by taking the platinum-iridium immortal references first thing in the test script, before loading anything that could break it. --- dist/Storable/t/blessed.t | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dist/Storable/t/blessed.t b/dist/Storable/t/blessed.t index fe439ac..352eb5f 100644 --- a/dist/Storable/t/blessed.t +++ b/dist/Storable/t/blessed.t @@ -6,6 +6,19 @@ # in the README file that comes with the distribution. # +BEGIN { + # Do this as the very first thing, in order to avoid problems with the + # PADTMP flag on pre-5.19.3 threaded Perls. On those Perls, compiling + # code that contains a constant-folded canonical truth value breaks + # the ability to take a reference to that canonical truth value later. + $::false = 0; + %::immortals = ( + 'u' => \undef, + 'y' => \!$::false, + 'n' => \!!$::false, + ); +} + sub BEGIN { unshift @INC, 't'; unshift @INC, 't/compat' if $] < 5.006002; @@ -20,12 +33,6 @@ use Test::More; use Storable qw(freeze thaw store retrieve); -%::immortals - = (u => \undef, - 'y' => \(1 == 1), - n => \(1 == 0) -); - { %::weird_refs = ( REF => \(my $aref = []), -- 1.8.3.1