In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/cf8db57b138fa07b34eff3066c16fa1bf0afdf63?hp=4b99cb86e7a8b76f83ce83aee0cf4408124de956>
- Log ----------------------------------------------------------------- commit cf8db57b138fa07b34eff3066c16fa1bf0afdf63 Author: Jarkko Hietaniemi <[email protected]> Date: Tue Aug 16 21:56:43 2016 -0400 The 48c0e89d broke minitest by unconditional use Hash::Util. ----------------------------------------------------------------------- Summary of changes: t/op/coreamp.t | 8 ++++++-- t/op/each.t | 58 +++++++++++++++++++++++++++++++++------------------------ t/op/hash.t | 15 +++++++++++---- t/op/sub_lval.t | 29 +++++++++++++++++------------ 4 files changed, 68 insertions(+), 42 deletions(-) diff --git a/t/op/coreamp.t b/t/op/coreamp.t index 5029eab..e2d2f10 100644 --- a/t/op/coreamp.t +++ b/t/op/coreamp.t @@ -14,7 +14,6 @@ BEGIN { $^P |= 0x100; } -use Hash::Util; no warnings 'experimental::smartmatch'; sub lis($$;$) { @@ -632,7 +631,12 @@ is &mykeys({ 1..4 }), 2, '&mykeys(\%hash) in scalar cx'; lis [sort &mykeys({1..4})], [1,3], '&mykeys(\%hash) in list cx'; is &mykeys([ 1..4 ]), 4, '&mykeys(\@array) in scalar cx'; lis [&mykeys([ 1..4 ])], [0..3], '&mykeys(\@array) in list cx'; -{ + +SKIP: { + skip "no Hash::Util on miniperl", 2, if is_miniperl; + require Hash::Util; + sub Hash::Util::bucket_ratio (\%); + my %h = 1..2; &mykeys(\%h) = 1024; like Hash::Util::bucket_ratio(%h), qr|/1024\z|, '&mykeys = changed number of buckets allocated'; diff --git a/t/op/each.t b/t/op/each.t index f9adc5c..f245a7e 100644 --- a/t/op/each.t +++ b/t/op/each.t @@ -5,7 +5,6 @@ BEGIN { @INC = '../lib'; require './test.pl'; } -use Hash::Util; plan tests => 59; @@ -61,20 +60,26 @@ is ($i, 30, "each count"); @keys = ('blurfl', keys(%h), 'dyick'); is ($#keys, 31, "added a key"); -$size = Hash::Util::num_buckets(%h); -keys %h = $size * 5; -$newsize = Hash::Util::num_buckets(%h); -is ($newsize, $size * 8, "resize"); -keys %h = 1; -$size = Hash::Util::num_buckets(%h); -is ($size, $newsize, "same size"); -%h = (1,1); -$size = Hash::Util::num_buckets(%h); -is ($size, $newsize, "still same size"); -undef %h; -%h = (1,1); -$size = Hash::Util::num_buckets(%h); -is ($size, 8, "size 8"); +SKIP: { + skip "no Hash::Util on miniperl", 4, if is_miniperl; + require Hash::Util; + sub Hash::Util::num_buckets (\%); + + $size = Hash::Util::num_buckets(%h); + keys %h = $size * 5; + $newsize = Hash::Util::num_buckets(%h); + is ($newsize, $size * 8, "resize"); + keys %h = 1; + $size = Hash::Util::num_buckets(%h); + is ($size, $newsize, "same size"); + %h = (1,1); + $size = Hash::Util::num_buckets(%h); + is ($size, $newsize, "still same size"); + undef %h; + %h = (1,1); + $size = Hash::Util::num_buckets(%h); + is ($size, 8, "size 8"); +} # test scalar each %hash = 1..20; @@ -99,15 +104,20 @@ $total = 0; $total += $key while $key = each %hash; is ($total, 100, "test values keys resets iterator"); -$size = Hash::Util::num_buckets(%hash); -keys(%hash) = $size / 2; -is ($size, Hash::Util::num_buckets(%hash), - "assign to keys does not shrink hash bucket array"); -keys(%hash) = $size + 100; -isnt ($size, Hash::Util::num_buckets(%hash), - "assignment to keys of a number not large enough does not change size"); - -is (keys(%hash), 10, "keys (%hash)"); +SKIP: { + skip "no Hash::Util on miniperl", 3, if is_miniperl; + require Hash::Util; + sub Hash::Util::num_buckets (\%); + + $size = Hash::Util::num_buckets(%hash); + keys(%hash) = $size / 2; + is ($size, Hash::Util::num_buckets(%hash), + "assign to keys does not shrink hash bucket array"); + keys(%hash) = $size + 100; + isnt ($size, Hash::Util::num_buckets(%hash), + "assignment to keys of a number not large enough does not change size"); + is (keys(%hash), 10, "keys (%hash)"); +} @tests = (&next_test, &next_test, &next_test); { diff --git a/t/op/hash.t b/t/op/hash.t index 1e5bc6d..1f8a550 100644 --- a/t/op/hash.t +++ b/t/op/hash.t @@ -7,7 +7,7 @@ BEGIN { } use strict; -use Hash::Util; + # This will crash perl if it fails use constant PVBM => 'foo'; @@ -134,6 +134,9 @@ sub validate_hash { is($scalar, $count, "$desc scalar() should be the same as 0+keys() as of perl 5.25"); + require Hash::Util; + sub Hash::Util::bucket_ratio (\%); + # back compat tests, via Hash::Util::bucket_ratio(); my $ratio = Hash::Util::bucket_ratio(%$h); my $expect = qr!\A(\d+)/(\d+)\z!; @@ -212,9 +215,13 @@ sub torture_hash { is(scalar %$h1, scalar %$h, "scalar keys is identical on copy and original"); } -torture_hash('a .. zz', 'a' .. 'zz'); -torture_hash('0 .. 9', 0 .. 9); -torture_hash("'Perl'", 'Rules'); +if (is_miniperl) { + print "# skipping torture_hash tests on miniperl because no Hash::Util\n"; +} else { + torture_hash('a .. zz', 'a' .. 'zz'); + torture_hash('0 .. 9', 0 .. 9); + torture_hash("'Perl'", 'Rules'); +} { my %h = qw(a x b y c z); diff --git a/t/op/sub_lval.t b/t/op/sub_lval.t index 59e286c..468b19a 100644 --- a/t/op/sub_lval.t +++ b/t/op/sub_lval.t @@ -6,7 +6,6 @@ BEGIN { require './test.pl'; } plan tests=>211; -use Hash::Util; sub a : lvalue { my $a = 34; ${\(bless \$a)} } # Return a temporary sub b : lvalue { ${\shift} } @@ -550,17 +549,23 @@ while (/f/g) { } is("@p", "1 8"); -sub keeze : lvalue { keys %__ } -%__ = ("a","b"); -keeze = 64; -is Hash::Util::bucket_ratio(%__), '1/64', 'keys assignment through lvalue sub'; -eval { (keeze) = 64 }; -like $@, qr/^Can't modify keys in list assignment at /, - 'list assignment to keys through lv sub is forbidden'; -sub akeeze : lvalue { keys @_ } -eval { (akeeze) = 64 }; -like $@, qr/^Can't modify keys on array in list assignment at /, - 'list assignment to keys @_ through lv sub is forbidden'; +SKIP: { + skip "no Hash::Util on miniperl", 3, if is_miniperl; + require Hash::Util; + sub Hash::Util::bucket_ratio (\%); + + sub keeze : lvalue { keys %__ } + %__ = ("a","b"); + keeze = 64; + is Hash::Util::bucket_ratio(%__), '1/64', 'keys assignment through lvalue sub'; + eval { (keeze) = 64 }; + like $@, qr/^Can't modify keys in list assignment at /, + 'list assignment to keys through lv sub is forbidden'; + sub akeeze : lvalue { keys @_ } + eval { (akeeze) = 64 }; + like $@, qr/^Can't modify keys on array in list assignment at /, + 'list assignment to keys @_ through lv sub is forbidden'; +} # Bug 20001223.002 (#5005): split thought that the list had only one element @ary = qw(4 5 6); -- Perl5 Master Repository
