| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
|
| 4 |
use lib 't/lib'; |
| 5 |
use T::RequireDateTime; |
| 6 |
|
| 7 |
use Test::More; |
| 8 |
|
| 9 |
use DateTime::TimeZone::Local; |
| 10 |
|
| 11 |
# We need to make sure that we can determine the local tz |
| 12 |
local $ENV{TZ} = 'America/Chicago'; |
| 13 |
|
| 14 |
local $^O = 'does_not_exist'; |
| 15 |
|
| 16 |
my @input = ( 1 .. 10 ); |
| 17 |
|
| 18 |
# Stack corruption from a failed use of eval to load a local subclass would |
| 19 |
# cause the sort to exit prematurely. |
| 20 |
|
| 21 |
## no critic (BuiltinFunctions::RequireSimpleSortBlock) |
| 22 |
my @output = sort { |
| 23 |
DateTime::TimeZone::Local->TimeZone(); |
| 24 |
$a <=> $b |
| 25 |
} @input; |
| 26 |
|
| 27 |
is_deeply( |
| 28 |
\@output, \@input, |
| 29 |
'calling DateTime::TimeZone::Local->TimeZone repeatedly in a sort block does not corrupt the stack' |
| 30 |
); |
| 31 |
|
| 32 |
done_testing(); |
| 33 |
|