diff -Nru libvar-pairs-perl-0.002000/Changes libvar-pairs-perl-0.002004/Changes --- libvar-pairs-perl-0.002000/Changes 2014-04-05 15:19:03.000000000 +0000 +++ libvar-pairs-perl-0.002004/Changes 2015-03-11 20:01:52.000000000 +0000 @@ -43,3 +43,39 @@ Added ->kv() to Pair type (thanks Toby) + + +0.002001 Wed Mar 11 20:04:58 2015 + + Swapped a doc nit (thanks Garry!) + + Documented non-resettable nature of each_kv() iterators + (i.e. they don't reset when the original hash is key()'d) + (thanks John) + + Allowed each_kv to work correctly on different containers + that are passed to the same call: each_kv( %{$some_ref} ) + (thanks John!) + + +0.002002 Wed Mar 11 20:13:33 2015 + + Allowed each_pair and pairs to also work correctly on different + containers that are passed to the same call + + + +0.002003 Wed Mar 11 20:42:14 2015 + + Fixed brittle testing approach in t/each_via_ref.t + (Thanks Slaven!) + + Neutralized irritating experimental warnings on reference operations + (Thanks Slaven) + + +0.002004 Wed Mar 11 21:01:52 2015 + + Sigh. Tweak experimentals warnings for 5.18. + (Thanks again Slaven) + diff -Nru libvar-pairs-perl-0.002000/debian/changelog libvar-pairs-perl-0.002004/debian/changelog --- libvar-pairs-perl-0.002000/debian/changelog 2014-04-05 17:33:08.000000000 +0000 +++ libvar-pairs-perl-0.002004/debian/changelog 2015-04-28 05:15:46.000000000 +0000 @@ -1,3 +1,19 @@ +libvar-pairs-perl (0.002004-2) unstable; urgency=medium + + * Upload to unstable + + -- Salvatore Bonaccorso Tue, 28 Apr 2015 07:14:51 +0200 + +libvar-pairs-perl (0.002004-1) experimental; urgency=medium + + * Update Vcs-Browser URL to cgit web frontend + * Imported Upstream version 0.002004 + * Update copyright years for debian/* packaging files + * Declare compliance with Debian policy 3.9.6 + * Add Testsuite: autopkgtest-pkg-perl field in debian/control + + -- Salvatore Bonaccorso Sat, 04 Apr 2015 14:54:03 +0200 + libvar-pairs-perl (0.002000-1) unstable; urgency=medium * Imported Upstream version 0.002000 diff -Nru libvar-pairs-perl-0.002000/debian/control libvar-pairs-perl-0.002004/debian/control --- libvar-pairs-perl-0.002000/debian/control 2014-04-05 17:33:08.000000000 +0000 +++ libvar-pairs-perl-0.002004/debian/control 2015-04-28 05:15:46.000000000 +0000 @@ -9,10 +9,11 @@ libdevel-callsite-perl, libpadwalker-perl (>= 1.93), perl (>= 5.14) -Standards-Version: 3.9.5 -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libvar-pairs-perl.git +Standards-Version: 3.9.6 +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libvar-pairs-perl.git Vcs-Git: git://anonscm.debian.org/pkg-perl/packages/libvar-pairs-perl.git Homepage: https://metacpan.org/release/Var-Pairs +Testsuite: autopkgtest-pkg-perl Package: libvar-pairs-perl Architecture: all diff -Nru libvar-pairs-perl-0.002000/debian/copyright libvar-pairs-perl-0.002004/debian/copyright --- libvar-pairs-perl-0.002000/debian/copyright 2014-04-05 17:33:08.000000000 +0000 +++ libvar-pairs-perl-0.002004/debian/copyright 2015-04-28 05:15:46.000000000 +0000 @@ -8,7 +8,7 @@ License: Artistic or GPL-1+ Files: debian/* -Copyright: 2013-2014, Salvatore Bonaccorso +Copyright: 2013-2015, Salvatore Bonaccorso License: Artistic or GPL-1+ License: Artistic diff -Nru libvar-pairs-perl-0.002000/lib/Var/Pairs.pm libvar-pairs-perl-0.002004/lib/Var/Pairs.pm --- libvar-pairs-perl-0.002000/lib/Var/Pairs.pm 2014-04-05 15:19:03.000000000 +0000 +++ libvar-pairs-perl-0.002004/lib/Var/Pairs.pm 2015-03-11 20:01:52.000000000 +0000 @@ -1,10 +1,11 @@ package Var::Pairs; -our $VERSION = '0.002000'; +our $VERSION = '0.002004'; use 5.014; use warnings; no if $] >= 5.018, warnings => "experimental::smartmatch"; +no if $] >= 5.020, warnings => "experimental::autoderef"; use Carp; use Devel::Callsite; @@ -116,7 +117,7 @@ } # Uniquely identify this call, according to its lexical context... - my $ID = callsite(); + my $ID = callsite() . $container_ref; # Short-circuit if this is a repeated call... if (!wantarray && $iterator_for{$ID}) { @@ -140,7 +141,7 @@ my ($container_ref) = @_; # Uniquely identify this call, according to its lexical context... - my $ID = callsite(); + my $ID = callsite() . $container_ref; # Build an iterator... $iterator_for{$ID} //= [ &pairs ]; @@ -167,7 +168,7 @@ } # Uniquely identify this call, according to its lexical context... - my $ID = callsite(); + my $ID = callsite() . $container_ref; # Return the key/value list, according to the container type... if ($container_type eq 'ARRAY') { @@ -181,8 +182,8 @@ sub each_kv (+) { my ($container_ref) = @_; - # Uniquely identify this call, according to its lexical context... - my $ID = callsite(); + # Uniquely identify this call, according to its lexical context and iteration target... + my $ID = callsite() . $container_ref; # Build an iterator... $iterator_for{$ID} //= [ &kvs ]; @@ -364,7 +365,7 @@ =head1 VERSION -This document describes Var::Pairs version 0.002000 +This document describes Var::Pairs version 0.002004 =head1 SYNOPSIS @@ -378,9 +379,9 @@ } - # next_pair() iterates OO pairs from arrays and hashes... + # each_pair() iterates OO pairs from arrays and hashes... - while (my $next = next_pair %hash) { + while (my $next = each_pair %hash) { say $next->key, ' had the value ', $next->value; $next->value++; } @@ -533,9 +534,11 @@ } In other words, C is a drop-in replacement for Perl's -built-in C, except that you can nest C -iterations over the same variable without shooting yourself in -the foot. +built-in C, with two exceptions: one an advantage, the other a +limitation. The advantage is that you can nest C iterations +over the same variable without shooting yourself in the foot. The +limitation is that, unlike C, C does not reset +when you call the C function on the hash you're iterating. =back @@ -868,6 +871,12 @@ C, or through the web interface at L. +C acts like a true one-time only iterator (in the OO sense), +so there is no way to reset its iteration (i.e. the way that calling +C on a hash or array, resets any C that is iterating +it). If you need to reset partially iterated hashes or arrays, you will +need to use some other mechanism to do so. + =head1 ACKNOWLEDGEMENTS diff -Nru libvar-pairs-perl-0.002000/Makefile.PL libvar-pairs-perl-0.002004/Makefile.PL --- libvar-pairs-perl-0.002000/Makefile.PL 2013-08-08 15:41:43.000000000 +0000 +++ libvar-pairs-perl-0.002004/Makefile.PL 2015-03-11 19:33:53.000000000 +0000 @@ -14,6 +14,7 @@ 'Devel::Callsite' => 0.06, 'Data::Alias' => 1.16, 'PadWalker' => 1.93, + 'experimental' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Var-Pairs-*' }, diff -Nru libvar-pairs-perl-0.002000/MANIFEST libvar-pairs-perl-0.002004/MANIFEST --- libvar-pairs-perl-0.002000/MANIFEST 2014-04-05 15:19:09.000000000 +0000 +++ libvar-pairs-perl-0.002004/MANIFEST 2015-03-11 20:01:54.000000000 +0000 @@ -22,4 +22,6 @@ t/to_pair.t t/nexted_kv_same_statement.t t/hash_while_kv.t -META.yml Module meta-data (added by MakeMaker) +t/each_via_ref.t +META.yml Module YAML meta-data (added by MakeMaker) +META.json Module JSON meta-data (added by MakeMaker) diff -Nru libvar-pairs-perl-0.002000/META.json libvar-pairs-perl-0.002004/META.json --- libvar-pairs-perl-0.002000/META.json 1970-01-01 00:00:00.000000000 +0000 +++ libvar-pairs-perl-0.002004/META.json 2015-03-11 20:01:54.000000000 +0000 @@ -0,0 +1,45 @@ +{ + "abstract" : "OO iterators and pair constructors for variables", + "author" : [ + "Damian Conway " + ], + "dynamic_config" : 1, + "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.142690", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Var-Pairs", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, + "prereqs" : { + "build" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "0" + } + }, + "runtime" : { + "requires" : { + "Data::Alias" : "1.16", + "Devel::Callsite" : "0.06", + "PadWalker" : "1.93", + "Test::More" : "0", + "experimental" : "0" + } + } + }, + "release_status" : "stable", + "version" : "0.002004" +} diff -Nru libvar-pairs-perl-0.002000/META.yml libvar-pairs-perl-0.002004/META.yml --- libvar-pairs-perl-0.002000/META.yml 2014-04-05 15:19:09.000000000 +0000 +++ libvar-pairs-perl-0.002004/META.yml 2015-03-11 20:01:54.000000000 +0000 @@ -1,25 +1,26 @@ ---- #YAML:1.0 -name: Var-Pairs -version: 0.002000 -abstract: OO iterators and pair constructors for variables +--- +abstract: 'OO iterators and pair constructors for variables' author: - - Damian Conway -license: perl -distribution_type: module -configure_requires: - ExtUtils::MakeMaker: 0 + - 'Damian Conway ' build_requires: - ExtUtils::MakeMaker: 0 -requires: - Data::Alias: 1.16 - Devel::Callsite: 0.06 - PadWalker: 1.93 - Test::More: 0 -no_index: - directory: - - t - - inc -generated_by: ExtUtils::MakeMaker version 6.57_05 + ExtUtils::MakeMaker: '0' +configure_requires: + ExtUtils::MakeMaker: '0' +dynamic_config: 1 +generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.142690' +license: perl meta-spec: - url: http://module-build.sourceforge.net/META-spec-v1.4.html - version: 1.4 + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Var-Pairs +no_index: + directory: + - t + - inc +requires: + Data::Alias: '1.16' + Devel::Callsite: '0.06' + PadWalker: '1.93' + Test::More: '0' + experimental: '0' +version: '0.002004' diff -Nru libvar-pairs-perl-0.002000/README libvar-pairs-perl-0.002004/README --- libvar-pairs-perl-0.002000/README 2014-04-05 15:19:03.000000000 +0000 +++ libvar-pairs-perl-0.002004/README 2015-03-11 20:01:52.000000000 +0000 @@ -1,4 +1,4 @@ -Var::Pairs version 0.002000 +Var::Pairs version 0.002004 This module exports a small number of subroutines that add some Perl 6 conveniences to Perl 5. Specifically, diff -Nru libvar-pairs-perl-0.002000/t/autobox.t libvar-pairs-perl-0.002004/t/autobox.t --- libvar-pairs-perl-0.002000/t/autobox.t 2013-08-08 15:39:29.000000000 +0000 +++ libvar-pairs-perl-0.002004/t/autobox.t 2015-03-11 19:59:54.000000000 +0000 @@ -1,5 +1,6 @@ use 5.014; no if $] >= 5.018, warnings => "experimental::smartmatch"; +no if $] >= 5.020, warnings => "experimental::autoderef"; use Test::More; plan eval { require autobox } diff -Nru libvar-pairs-perl-0.002000/t/each_via_ref.t libvar-pairs-perl-0.002004/t/each_via_ref.t --- libvar-pairs-perl-0.002000/t/each_via_ref.t 1970-01-01 00:00:00.000000000 +0000 +++ libvar-pairs-perl-0.002004/t/each_via_ref.t 2015-03-11 19:30:38.000000000 +0000 @@ -0,0 +1,42 @@ +use 5.014; +no if $] >= 5.018, warnings => "experimental::smartmatch"; +use strict; +use Test::More tests => 24; + +use Var::Pairs; + +my %data1 = ( 1 => 'a', 2 => 'b' ); +my %data2 = ( 1 => 'aa', 2 => 'bb' ); + +my $next_ref = \%data1; + +while (my ($key, $value) = each_kv %{$next_ref}) { + ok exists $next_ref->{$key} => 'Valid key returned'; + is $next_ref->{$key}, $value => 'Correct value returned'; + + $next_ref = $next_ref == \%data1 ? \%data2 : \%data1; +} + + +$next_ref = \%data1; + +my $next_expected = 0; +while (my $pair = each_pair %{$next_ref}) { + ok exists $next_ref->{$pair->key} => 'Valid key returned'; + is $next_ref->{$pair->key}, $pair->value => 'Correct value returned'; + + $next_ref = $next_ref == \%data1 ? \%data2 : \%data1; +} + + + +for my $next_ref (\%data1, \%data2) { + for my $pair (pairs %{$next_ref}) { + ok exists $next_ref->{$pair->key} => 'Valid key returned'; + is $next_ref->{$pair->key}, $pair->value => 'Correct value returned'; + } +} + + + + diff -Nru libvar-pairs-perl-0.002000/t/hashref.t libvar-pairs-perl-0.002004/t/hashref.t --- libvar-pairs-perl-0.002000/t/hashref.t 2013-08-08 15:39:35.000000000 +0000 +++ libvar-pairs-perl-0.002004/t/hashref.t 2015-03-11 20:00:13.000000000 +0000 @@ -1,5 +1,6 @@ use 5.014; no if $] >= 5.018, warnings => "experimental::smartmatch"; +no if $] >= 5.020, warnings => "experimental::autoderef"; use strict; use Test::More tests => 13;