[libvar-pairs-perl] 01/01: Imported Upstream version 0.001003

Salvatore Bonaccorso carnil at debian.org
Thu Aug 8 18:33:43 UTC 2013


This is an automated email from the git hooks/post-receive script.

carnil pushed a commit to annotated tag upstream/0.001003
in repository libvar-pairs-perl.

commit 7da99d90ff3834ad786b49dfa90dd21a74a1f18d
Author: Salvatore Bonaccorso <carnil at debian.org>
Date:   Thu Aug 8 19:58:56 2013 +0200

    Imported Upstream version 0.001003
---
 Changes                      |    7 +++++++
 MANIFEST                     |    1 +
 META.yml                     |   10 +++++-----
 Makefile.PL                  |    8 ++++----
 README                       |    2 +-
 lib/Var/Pairs.pm             |   26 +++++++++-----------------
 t/autobox.t                  |    3 ++-
 t/hash.t                     |    1 +
 t/hash_while.t               |    1 +
 t/hashref.t                  |    1 +
 t/nexted_kv_same_statement.t |   23 +++++++++++++++++++++++
 t/one_liner.t                |   10 ++--------
 12 files changed, 57 insertions(+), 36 deletions(-)

diff --git a/Changes b/Changes
index 35488da..d032ec2 100644
--- a/Changes
+++ b/Changes
@@ -21,3 +21,10 @@ Revision history for Var-Pairs
 
     Removed autobox dependency for t/kvs.t
     (Thanks Salvatore!)
+
+
+0.001003  Thu Aug  8 11:46:09 2013
+
+    Converted to use Devel::Callsite instead of Scope::Upper
+    in order to identify caller location for the each_...
+    family of functions.
diff --git a/MANIFEST b/MANIFEST
index 441fdbd..90f15f4 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -20,4 +20,5 @@ t/nested.t
 t/nested_kv.t
 t/one_liner.t
 t/to_pair.t
+t/nexted_kv_same_statement.t
 META.yml                                 Module meta-data (added by MakeMaker)
diff --git a/META.yml b/META.yml
index a59a713..0b6761a 100644
--- a/META.yml
+++ b/META.yml
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Var-Pairs
-version:            0.001002
+version:            0.001003
 abstract:           OO iterators and pair constructors for variables
 author:
     - Damian Conway <DCONWAY at CPAN.org>
@@ -11,10 +11,10 @@ configure_requires:
 build_requires:
     ExtUtils::MakeMaker:  0
 requires:
-    Data::Alias:   1.16
-    PadWalker:     1.93
-    Scope::Upper:  0.18
-    Test::More:    0
+    Data::Alias:      1.16
+    Devel::Callsite:  0.06
+    PadWalker:        1.93
+    Test::More:       0
 no_index:
     directory:
         - t
diff --git a/Makefile.PL b/Makefile.PL
index 862551a..e263707 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -10,10 +10,10 @@ WriteMakefile(
     PL_FILES            => {},
     LICENSE             => 'perl',
     PREREQ_PM => {
-        'Test::More'   => 0,
-        'Scope::Upper' => 0.18,
-        'Data::Alias'  => 1.16,
-        'PadWalker'    => 1.93,
+        'Test::More'      => 0,
+        'Devel::Callsite' => 0.06,
+        'Data::Alias'     => 1.16,
+        'PadWalker'       => 1.93,
     },
     dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
     clean               => { FILES => 'Var-Pairs-*' },
diff --git a/README b/README
index 69957bd..9dde32e 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Var::Pairs version 0.001002
+Var::Pairs version 0.001003
 
 This module exports a small number of subroutines that
 add some Perl 6 conveniences to Perl 5. Specifically,
diff --git a/lib/Var/Pairs.pm b/lib/Var/Pairs.pm
index 89e1dbe..a90e30c 100644
--- a/lib/Var/Pairs.pm
+++ b/lib/Var/Pairs.pm
@@ -1,10 +1,12 @@
 package Var::Pairs;
 
-our $VERSION = '0.001002';
+our $VERSION = '0.001003';
 
 use 5.014;
 use warnings;
+no if $] >= 5.018, warnings => "experimental::smartmatch";
 use Carp;
+use Devel::Callsite;
 
 # Check for autoboxing, and set up pairs() method if applicable..
 my $autoboxing;
@@ -101,7 +103,7 @@ sub pairs (+) {
     }
 
     # Uniquely identify this call, according to its lexical context...
-    my $ID = _uniq_ID($container_ref);
+    my $ID = callsite();
 
     # Short-circuit if this is a repeated call...
     if (!wantarray && $iterator_for{$ID}) {
@@ -125,7 +127,7 @@ sub each_pair (+) {
     my ($container_ref) = @_;
 
     # Uniquely identify this call, according to its lexical context...
-    my $ID = _uniq_ID($container_ref);
+    my $ID = callsite();
 
     # Build an iterator...
     $iterator_for{$ID} //= [ &pairs ];
@@ -152,7 +154,7 @@ sub kvs (+) {
     }
 
     # Uniquely identify this call, according to its lexical context...
-    my $ID = _uniq_ID($container_ref);
+    my $ID = callsite();
 
     # Return the key/value list, according to the container type...
     if ($container_type eq 'ARRAY') {
@@ -167,7 +169,7 @@ sub each_kv (+) {
     my ($container_ref) = @_;
 
     # Uniquely identify this call, according to its lexical context...
-    my $ID = _uniq_ID($container_ref);
+    my $ID = callsite();
 
     # Build an iterator...
     $iterator_for{$ID} //= [ &kvs ];
@@ -317,16 +319,6 @@ package Var::Pairs::Pair {
     );
 }
 
-# Create a unique identifier for a given call to pairs()...
-sub _uniq_ID {
-    my $container_ref = shift;
-
-    # ID is based on file, line, subname, hints, and caller scope...
-    require Scope::Upper;
-    return join '|', (caller 1)[1..3,8], Scope::Upper::UP(Scope::Upper::UP());
-}
-
-
 1; # Magic true value required at end of module
 __END__
 
@@ -338,7 +330,7 @@ Var::Pairs - OO iterators and pair constructors for variables
 
 =head1 VERSION
 
-This document describes Var::Pairs version 0.001002
+This document describes Var::Pairs version 0.001003
 
 
 =head1 SYNOPSIS
@@ -797,7 +789,7 @@ The module requires Perl 5.014 and the following modules:
 
 =item Perl 5.14 or later
 
-=item Scope::Upper
+=item Devel::Callsite
 
 =item Data::Alias
 
diff --git a/t/autobox.t b/t/autobox.t
index 641fb2f..8afe82c 100644
--- a/t/autobox.t
+++ b/t/autobox.t
@@ -1,5 +1,6 @@
 use 5.014;
-use Test::More; 
+no if $] >= 5.018, warnings => "experimental::smartmatch";
+use Test::More;
 
 plan eval { require autobox }
     ? (tests => 25)
diff --git a/t/hash.t b/t/hash.t
index 157fb69..93393f8 100644
--- a/t/hash.t
+++ b/t/hash.t
@@ -1,5 +1,6 @@
 use 5.014;
 use strict;
+no if $] >= 5.018, warnings => "experimental::smartmatch";
 use Test::More tests => 13;
 
 use Var::Pairs;
diff --git a/t/hash_while.t b/t/hash_while.t
index 7e4ca2c..478d818 100644
--- a/t/hash_while.t
+++ b/t/hash_while.t
@@ -1,4 +1,5 @@
 use 5.014;
+no if $] >= 5.018, warnings => "experimental::smartmatch";
 use strict;
 use Test::More tests => 13;
 
diff --git a/t/hashref.t b/t/hashref.t
index b9a529b..31c8b64 100644
--- a/t/hashref.t
+++ b/t/hashref.t
@@ -1,4 +1,5 @@
 use 5.014;
+no if $] >= 5.018, warnings => "experimental::smartmatch";
 use strict;
 use Test::More tests => 13;
 
diff --git a/t/nexted_kv_same_statement.t b/t/nexted_kv_same_statement.t
new file mode 100644
index 0000000..cc0b9af
--- /dev/null
+++ b/t/nexted_kv_same_statement.t
@@ -0,0 +1,23 @@
+use 5.014;
+use strict;
+use Test::More;
+
+use Var::Pairs;
+
+my @data = 'a'..'f';
+
+plan tests => 1 + 2 * @data;
+
+my ($iter1, $iter2);
+while (my ($key1, $val1) = each_kv(@data) and my ($key2, $val2) = each_kv(@data)) {
+    state $count = 0;
+    $count++;
+    is $key1, $key2 => "Iterated key in parallel ($key1)";
+    is $val1, $val2 => "Iterated value in parallel ($val1)";
+    END {
+        cmp_ok $count, '==', @data => "correct number of iterations";
+    }
+}
+
+
+
diff --git a/t/one_liner.t b/t/one_liner.t
index 32420a3..0ab860b 100644
--- a/t/one_liner.t
+++ b/t/one_liner.t
@@ -4,10 +4,7 @@ use Test::More tests => 3;
 
 use Var::Pairs;
 
-
-SKIP: {
-    skip "Can't put two calls to pair() on one line without Scope::Upper" => 1
-        if !eval{ require Scope::Upper };
+{
     my @results;
     my @data = 'a'..'f';
     for my $next1 (pairs @data) { for my $next2 (pairs @data) {
@@ -27,10 +24,7 @@ SKIP: {
     is_deeply \@results, ['a'..'f','a'..'f']  => 'repeated pairs';
 }
 
-SKIP: {
-    skip "Can't put two calls to pair() on one line without Scope::Upper" => 1
-        if !eval{ require Scope::Upper };
-
+{
     my @data = 'a'..'f';
 
     while (my $next_outer = each_pair @data) { while (my $next_inner = each_pair @data) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libvar-pairs-perl.git



More information about the Pkg-perl-cvs-commits mailing list