@@ -12,7 +12,6 @@ BEGIN {
12
12
skip_all_without_config(' d_fork' );
13
13
}
14
14
15
- # plan tests => 112;
16
15
plan tests => 6;
17
16
18
17
my $STDOUT = tempfile();
@@ -62,6 +61,7 @@ sub runperl_and_capture {
62
61
}
63
62
}
64
63
64
+ our $TODO ;
65
65
SKIP:
66
66
{
67
67
# skip "NO_PERL_HASH_ENV or NO_PERL_HASH_SEED_DEBUG set", 16
@@ -71,19 +71,23 @@ SKIP:
71
71
72
72
# Test that PERL_PERTURB_KEYS works as expected. We check that we get the same
73
73
# results if we use PERL_PERTURB_KEYS = 0 or 2 and we reuse the seed from previous run.
74
- my @print_keys = ( ' -e' , ' @_ {"A".."Z"}=(); print keys %_ ' );
75
- for my $mode ( 0,1, 2 ) { # disabled and deterministic respectively
74
+ my @print_keys = ( ' -e' , ' my %h; @h {"A".."Z"}=(); print keys %h ' );
75
+ for my $mode ( qw{ NO RANDOM DETERMINISTIC } ) { # 0, 1 and 2 respectively
76
76
my %base_opts ;
77
77
%base_opts = ( PERL_PERTURB_KEYS => $mode , PERL_HASH_SEED_DEBUG => 1 ),
78
78
my ($out , $err ) = runperl_and_capture( { %base_opts }, [ @print_keys ]);
79
79
if ($err =~/ HASH_SEED = (0x[a-f0-9]+)/ ) {
80
80
my $seed = $1 ;
81
81
my ($out2 , $err2 ) = runperl_and_capture( { %base_opts , PERL_HASH_SEED => $seed }, [ @print_keys ]);
82
- if ( $mode == 1 ) {
82
+ if ( $mode eq ' RANDOM ' ) {
83
83
isnt ($out ,$out2 ," PERL_PERTURB_KEYS = $mode results in different key order with the same key" );
84
- } else {
84
+ } elsif ( $mode eq ' NO' ) {
85
+ is ($out ,$out2 ," PERL_PERTURB_KEYS = $mode allows one to recreate a random hash" );
86
+ } elsif ( $mode eq ' DETERMINISTIC' ) {
87
+ local $TODO = q[ need to check DETERMINISTIC mode] ;
85
88
is ($out ,$out2 ," PERL_PERTURB_KEYS = $mode allows one to recreate a random hash" );
86
89
}
90
+
87
91
is ($err ,$err2 ," Got the same debug output when we set PERL_HASH_SEED and PERL_PERTURB_KEYS" );
88
92
}
89
93
}
0 commit comments