summaryrefslogtreecommitdiff
path: root/cpan/Scalar-List-Utils
diff options
context:
space:
mode:
authorLeon Timmermans <fawaka@gmail.com>2021-10-19 22:58:43 +0200
committerLeon Timmermans <fawaka@gmail.com>2021-10-19 22:58:43 +0200
commit741719f192c88023e3b46b3353882c1345830361 (patch)
tree0263af122ec0c3daddac9ba926bfd585ee65d2bb /cpan/Scalar-List-Utils
parent875873b0b9366a69b192a88c628ad75a718ff306 (diff)
downloadperl-741719f192c88023e3b46b3353882c1345830361.tar.gz
Update Scalar-List-Util to 1.60
Diffstat (limited to 'cpan/Scalar-List-Utils')
-rw-r--r--cpan/Scalar-List-Utils/ListUtil.xs156
-rw-r--r--cpan/Scalar-List-Utils/lib/List/Util.pm2
-rw-r--r--cpan/Scalar-List-Utils/lib/List/Util/XS.pm2
-rw-r--r--cpan/Scalar-List-Utils/lib/Scalar/Util.pm63
-rw-r--r--cpan/Scalar-List-Utils/lib/Sub/Util.pm2
-rw-r--r--cpan/Scalar-List-Utils/t/boolean-thr.t38
-rw-r--r--cpan/Scalar-List-Utils/t/boolean.t64
-rw-r--r--cpan/Scalar-List-Utils/t/dualvar.t9
-rw-r--r--cpan/Scalar-List-Utils/t/first.t2
-rw-r--r--cpan/Scalar-List-Utils/t/isvstring.t4
-rw-r--r--cpan/Scalar-List-Utils/t/pair.t3
-rw-r--r--cpan/Scalar-List-Utils/t/product.t9
-rw-r--r--cpan/Scalar-List-Utils/t/reduce.t2
-rw-r--r--cpan/Scalar-List-Utils/t/reductions.t2
-rw-r--r--cpan/Scalar-List-Utils/t/undefined-block.t18
-rw-r--r--cpan/Scalar-List-Utils/t/weak.t8
16 files changed, 115 insertions, 269 deletions
diff --git a/cpan/Scalar-List-Utils/ListUtil.xs b/cpan/Scalar-List-Utils/ListUtil.xs
index bd655010d5..c6b3c28d81 100644
--- a/cpan/Scalar-List-Utils/ListUtil.xs
+++ b/cpan/Scalar-List-Utils/ListUtil.xs
@@ -240,6 +240,22 @@ static double MY_callrand(pTHX_ CV *randcv)
return ret;
}
+#define sv_to_cv(sv, subname) MY_sv_to_cv(aTHX_ sv, subname);
+static CV* MY_sv_to_cv(pTHX_ SV* sv, const char * const subname)
+{
+ GV *gv;
+ HV *stash;
+ CV *cv = sv_2cv(sv, &stash, &gv, 0);
+
+ if(cv == Nullcv)
+ croak("Not a subroutine reference");
+
+ if(!CvROOT(cv) && !CvXSUB(cv))
+ croak("Undefined subroutine in %s", subname);
+
+ return cv;
+}
+
enum {
ZIP_SHORTEST = 1,
ZIP_LONGEST = 2,
@@ -390,7 +406,7 @@ CODE:
IV i = SvIV(sv);
if (retiv == 0) /* avoid later division by zero */
break;
- if (retiv < 0) {
+ if (retiv < -1) { /* avoid -1 because that causes SIGFPE */
if (i < 0) {
if (i >= IV_MAX / retiv) {
retiv *= i;
@@ -404,7 +420,7 @@ CODE:
}
}
}
- else {
+ else if (retiv > 0) {
if (i < 0) {
if (i >= IV_MIN / retiv) {
retiv *= i;
@@ -532,14 +548,10 @@ CODE:
{
SV *ret = sv_newmortal();
int index;
- AV *retvals;
- GV *agv,*bgv,*gv;
- HV *stash;
+ AV *retvals = NULL;
+ GV *agv,*bgv;
SV **args = &PL_stack_base[ax];
- CV *cv = sv_2cv(block, &stash, &gv, 0);
-
- if(cv == Nullcv)
- croak("Not a subroutine reference");
+ CV *cv = sv_to_cv(block, ix ? "reductions" : "reduce");
if(items <= 1) {
if(ix)
@@ -626,13 +638,8 @@ PROTOTYPE: &@
CODE:
{
int index;
- GV *gv;
- HV *stash;
SV **args = &PL_stack_base[ax];
- CV *cv = sv_2cv(block, &stash, &gv, 0);
-
- if(cv == Nullcv)
- croak("Not a subroutine reference");
+ CV *cv = sv_to_cv(block, "first");
if(items <= 1)
XSRETURN_UNDEF;
@@ -701,13 +708,13 @@ PPCODE:
{
int ret_true = !(ix & 2); /* return true at end of loop for none/all; false for any/notall */
int invert = (ix & 1); /* invert block test for all/notall */
- GV *gv;
- HV *stash;
SV **args = &PL_stack_base[ax];
- CV *cv = sv_2cv(block, &stash, &gv, 0);
-
- if(cv == Nullcv)
- croak("Not a subroutine reference");
+ CV *cv = sv_to_cv(block,
+ ix == 0 ? "none" :
+ ix == 1 ? "all" :
+ ix == 2 ? "any" :
+ ix == 3 ? "notall" :
+ "unknown 'any' alias");
SAVESPTR(GvSV(PL_defgv));
#ifdef dMULTICALL
@@ -930,9 +937,8 @@ pairfirst(block,...)
PROTOTYPE: &@
PPCODE:
{
- GV *agv,*bgv,*gv;
- HV *stash;
- CV *cv = sv_2cv(block, &stash, &gv, 0);
+ GV *agv,*bgv;
+ CV *cv = sv_to_cv(block, "pairfirst");
I32 ret_gimme = GIMME_V;
int argi = 1; /* "shift" the block */
@@ -964,7 +970,7 @@ PPCODE:
continue;
POP_MULTICALL;
- if(ret_gimme == G_ARRAY) {
+ if(ret_gimme == G_LIST) {
ST(0) = sv_mortalcopy(a);
ST(1) = sv_mortalcopy(b);
XSRETURN(2);
@@ -991,7 +997,7 @@ PPCODE:
if(!SvTRUEx(*PL_stack_sp))
continue;
- if(ret_gimme == G_ARRAY) {
+ if(ret_gimme == G_LIST) {
ST(0) = sv_mortalcopy(a);
ST(1) = sv_mortalcopy(b);
XSRETURN(2);
@@ -1010,9 +1016,8 @@ pairgrep(block,...)
PROTOTYPE: &@
PPCODE:
{
- GV *agv,*bgv,*gv;
- HV *stash;
- CV *cv = sv_2cv(block, &stash, &gv, 0);
+ GV *agv,*bgv;
+ CV *cv = sv_to_cv(block, "pairgrep");
I32 ret_gimme = GIMME_V;
/* This function never returns more than it consumed in arguments. So we
@@ -1047,7 +1052,7 @@ PPCODE:
MULTICALL;
if(SvTRUEx(*PL_stack_sp)) {
- if(ret_gimme == G_ARRAY) {
+ if(ret_gimme == G_LIST) {
/* We can't mortalise yet or they'd be mortal too early */
stack[reti++] = newSVsv(a);
stack[reti++] = newSVsv(b);
@@ -1058,7 +1063,7 @@ PPCODE:
}
POP_MULTICALL;
- if(ret_gimme == G_ARRAY)
+ if(ret_gimme == G_LIST)
for(i = 0; i < reti; i++)
sv_2mortal(stack[i]);
}
@@ -1076,7 +1081,7 @@ PPCODE:
SPAGAIN;
if(SvTRUEx(*PL_stack_sp)) {
- if(ret_gimme == G_ARRAY) {
+ if(ret_gimme == G_LIST) {
ST(reti++) = sv_mortalcopy(a);
ST(reti++) = sv_mortalcopy(b);
}
@@ -1086,7 +1091,7 @@ PPCODE:
}
}
- if(ret_gimme == G_ARRAY)
+ if(ret_gimme == G_LIST)
XSRETURN(reti);
else if(ret_gimme == G_SCALAR) {
ST(0) = newSViv(reti);
@@ -1100,9 +1105,8 @@ pairmap(block,...)
PROTOTYPE: &@
PPCODE:
{
- GV *agv,*bgv,*gv;
- HV *stash;
- CV *cv = sv_2cv(block, &stash, &gv, 0);
+ GV *agv,*bgv;
+ CV *cv = sv_to_cv(block, "pairmap");
SV **args_copy = NULL;
I32 ret_gimme = GIMME_V;
@@ -1129,7 +1133,7 @@ PPCODE:
AV *spill = NULL; /* accumulates results if too big for stack */
dMULTICALL;
- I32 gimme = G_ARRAY;
+ I32 gimme = G_LIST;
UNUSED_VAR_newsp;
PUSH_MULTICALL(cv);
@@ -1173,11 +1177,12 @@ PPCODE:
stack[reti++] = newSVsv(PL_stack_base[i + 1]);
}
- if (spill)
+ if (spill) {
/* the POP_MULTICALL will trigger the SAVEFREESV above;
* keep it alive it on the temps stack instead */
SvREFCNT_inc_simple_void_NN(spill);
sv_2mortal((SV*)spill);
+ }
POP_MULTICALL;
@@ -1191,7 +1196,7 @@ PPCODE:
av_clear(spill);
}
- if(ret_gimme == G_ARRAY)
+ if(ret_gimme == G_LIST)
for(i = 0; i < reti; i++)
sv_2mortal(ST(i));
}
@@ -1209,11 +1214,11 @@ PPCODE:
&PL_sv_undef;
PUSHMARK(SP);
- count = call_sv((SV*)cv, G_ARRAY);
+ count = call_sv((SV*)cv, G_LIST);
SPAGAIN;
- if(count > 2 && !args_copy && ret_gimme == G_ARRAY) {
+ if(count > 2 && !args_copy && ret_gimme == G_LIST) {
int n_args = items - argi;
Newx(args_copy, n_args, SV *);
SAVEFREEPV(args_copy);
@@ -1224,7 +1229,7 @@ PPCODE:
items = n_args;
}
- if(ret_gimme == G_ARRAY)
+ if(ret_gimme == G_LIST)
for(i = 0; i < count; i++)
ST(reti++) = sv_mortalcopy(SP[i - count + 1]);
else
@@ -1234,7 +1239,7 @@ PPCODE:
}
}
- if(ret_gimme == G_ARRAY)
+ if(ret_gimme == G_LIST)
XSRETURN(reti);
ST(0) = sv_2mortal(newSViv(reti));
@@ -1354,7 +1359,7 @@ CODE:
seen_undef++;
- if(GIMME_V == G_ARRAY)
+ if(GIMME_V == G_LIST)
ST(retcount) = arg;
retcount++;
continue;
@@ -1402,13 +1407,13 @@ CODE:
hv_store_ent(seen, arg, &PL_sv_yes, 0);
#endif
- if(GIMME_V == G_ARRAY)
+ if(GIMME_V == G_LIST)
ST(retcount) = SvOK(arg) ? arg : sv_2mortal(newSVpvn("", 0));
retcount++;
}
finish:
- if(GIMME_V == G_ARRAY)
+ if(GIMME_V == G_LIST)
XSRETURN(retcount);
else
ST(0) = sv_2mortal(newSViv(retcount));
@@ -1558,13 +1563,13 @@ CODE:
hv_store(seen, SvPVX(keysv), SvCUR(keysv), &PL_sv_yes, 0);
#endif
- if(GIMME_V == G_ARRAY)
+ if(GIMME_V == G_LIST)
ST(retcount) = SvOK(arg) ? arg : sv_2mortal(newSViv(0));
retcount++;
}
finish:
- if(GIMME_V == G_ARRAY)
+ if(GIMME_V == G_LIST)
XSRETURN(retcount);
else
ST(0) = sv_2mortal(newSViv(retcount));
@@ -1579,10 +1584,10 @@ ALIAS:
mesh_longest = ZIP_MESH_LONGEST
mesh_shortest = ZIP_MESH_SHORTEST
PPCODE:
- UV nlists = items; /* number of lists */
- AV **lists; /* inbound lists */
- UV len = 0; /* length of longest inbound list = length of result */
- UV i;
+ int nlists = items; /* number of lists */
+ AV **lists; /* inbound lists */
+ int len = 0; /* length of longest inbound list = length of result */
+ int i;
bool is_mesh = (ix & ZIP_MESH);
ix &= ~ZIP_MESH;
@@ -1623,12 +1628,12 @@ PPCODE:
}
if(is_mesh) {
- UV retcount = len * nlists;
+ int retcount = len * nlists;
EXTEND(SP, retcount);
for(i = 0; i < len; i++) {
- UV listi;
+ int listi;
for(listi = 0; listi < nlists; listi++) {
SV *item = (i < av_count(lists[listi])) ?
@@ -1645,7 +1650,7 @@ PPCODE:
EXTEND(SP, len);
for(i = 0; i < len; i++) {
- UV listi;
+ int listi;
AV *ret = newAV();
av_extend(ret, nlists);
@@ -1666,19 +1671,6 @@ PPCODE:
MODULE=List::Util PACKAGE=Scalar::Util
void
-isbool(sv)
- SV *sv
-PROTOTYPE: $
-CODE:
-#ifdef SvIsBOOL
- SvGETMAGIC(sv);
- ST(0) = boolSV(SvIsBOOL(sv));
- XSRETURN(1);
-#else
- croak("stable boolean values are not implemented in this release of perl");
-#endif
-
-void
dualvar(num,str)
SV *num
SV *str
@@ -1780,11 +1772,7 @@ weaken(sv)
SV *sv
PROTOTYPE: $
CODE:
-#ifdef SvWEAKREF
sv_rvweaken(sv);
-#else
- croak("weak references are not implemented in this release of perl");
-#endif
void
unweaken(sv)
@@ -1796,7 +1784,7 @@ CODE:
#if defined(sv_rvunweaken)
PERL_UNUSED_VAR(tsv);
sv_rvunweaken(sv);
-#elif defined(SvWEAKREF)
+#else
/* This code stolen from core's sv_rvweaken() and modified */
if (!SvOK(sv))
return;
@@ -1822,8 +1810,6 @@ CODE:
SvRV_set(sv, SvREFCNT_inc_NN(tsv));
SvROK_on(sv);
#endif
-#else
- croak("weak references are not implemented in this release of perl");
#endif
void
@@ -1831,12 +1817,8 @@ isweak(sv)
SV *sv
PROTOTYPE: $
CODE:
-#ifdef SvWEAKREF
ST(0) = boolSV(SvROK(sv) && SvWEAKREF(sv));
XSRETURN(1);
-#else
- croak("weak references are not implemented in this release of perl");
-#endif
int
readonly(sv)
@@ -2042,12 +2024,13 @@ PPCODE:
}
if (old_data && HeVAL(old_data)) {
+ SV* old_val = HeVAL(old_data);
SV* new_full_name = sv_2mortal(newSVpvn_flags(HvNAME(stash), HvNAMELEN_get(stash), HvNAMEUTF8(stash) ? SVf_UTF8 : 0));
sv_catpvn(new_full_name, "::", 2);
sv_catpvn_flags(new_full_name, nameptr, s - nameptr, utf8flag ? SV_CATUTF8 : SV_CATBYTES);
- SvREFCNT_inc(HeVAL(old_data));
- if (hv_store_ent(DBsub, new_full_name, HeVAL(old_data), 0) != NULL)
- SvREFCNT_inc(HeVAL(old_data));
+ SvREFCNT_inc(old_val);
+ if (!hv_store_ent(DBsub, new_full_name, old_val, 0))
+ SvREFCNT_dec(old_val);
}
}
@@ -2114,7 +2097,7 @@ BOOT:
HV *lu_stash = gv_stashpvn("List::Util", 10, TRUE);
GV *rmcgv = *(GV**)hv_fetch(lu_stash, "REAL_MULTICALL", 14, TRUE);
SV *rmcsv;
-#if !defined(SvWEAKREF) || !defined(SvVOK) || !defined(SvIsBOOL)
+#if !defined(SvVOK)
HV *su_stash = gv_stashpvn("Scalar::Util", 12, TRUE);
GV *vargv = *(GV**)hv_fetch(su_stash, "EXPORT_FAIL", 11, TRUE);
AV *varav;
@@ -2125,16 +2108,9 @@ BOOT:
if(SvTYPE(rmcgv) != SVt_PVGV)
gv_init(rmcgv, lu_stash, "List::Util", 10, TRUE);
rmcsv = GvSVn(rmcgv);
-#ifndef SvWEAKREF
- av_push(varav, newSVpv("weaken",6));
- av_push(varav, newSVpv("isweak",6));
-#endif
#ifndef SvVOK
av_push(varav, newSVpv("isvstring",9));
#endif
-#ifndef SvIsBOOL
- av_push(varav, newSVpv("isbool",6));
-#endif
#ifdef REAL_MULTICALL
sv_setsv(rmcsv, &PL_sv_yes);
#else
diff --git a/cpan/Scalar-List-Utils/lib/List/Util.pm b/cpan/Scalar-List-Utils/lib/List/Util.pm
index 71f36f1956..9dc233a151 100644
--- a/cpan/Scalar-List-Utils/lib/List/Util.pm
+++ b/cpan/Scalar-List-Utils/lib/List/Util.pm
@@ -16,7 +16,7 @@ our @EXPORT_OK = qw(
sample shuffle uniq uniqint uniqnum uniqstr zip zip_longest zip_shortest mesh mesh_longest mesh_shortest
head tail pairs unpairs pairkeys pairvalues pairmap pairgrep pairfirst
);
-our $VERSION = "1.56_001";
+our $VERSION = "1.60";
our $XS_VERSION = $VERSION;
$VERSION =~ tr/_//d;
diff --git a/cpan/Scalar-List-Utils/lib/List/Util/XS.pm b/cpan/Scalar-List-Utils/lib/List/Util/XS.pm
index 77cb68fc97..e8e78b2ae7 100644
--- a/cpan/Scalar-List-Utils/lib/List/Util/XS.pm
+++ b/cpan/Scalar-List-Utils/lib/List/Util/XS.pm
@@ -3,7 +3,7 @@ use strict;
use warnings;
use List::Util;
-our $VERSION = "1.56_001"; # FIXUP
+our $VERSION = "1.60"; # FIXUP
$VERSION =~ tr/_//d; # FIXUP
1;
diff --git a/cpan/Scalar-List-Utils/lib/Scalar/Util.pm b/cpan/Scalar-List-Utils/lib/Scalar/Util.pm
index feb59806c6..a65d923ef0 100644
--- a/cpan/Scalar-List-Utils/lib/Scalar/Util.pm
+++ b/cpan/Scalar-List-Utils/lib/Scalar/Util.pm
@@ -14,45 +14,22 @@ our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
blessed refaddr reftype weaken unweaken isweak
- isbool
-
dualvar isdual isvstring looks_like_number openhandle readonly set_prototype
tainted
);
-our $VERSION = "1.56_001";
+our $VERSION = "1.60";
$VERSION =~ tr/_//d;
require List::Util; # List::Util loads the XS
List::Util->VERSION( $VERSION ); # Ensure we got the right XS version (RT#100863)
-our @EXPORT_FAIL;
-
-unless (defined &weaken) {
- push @EXPORT_FAIL, qw(weaken);
-}
-unless (defined &isweak) {
- push @EXPORT_FAIL, qw(isweak isvstring);
-}
-unless (defined &isvstring) {
- push @EXPORT_FAIL, qw(isvstring);
-}
-
+# populating @EXPORT_FAIL is done in the XS code
sub export_fail {
- if (grep { /^(?:weaken|isweak)$/ } @_ ) {
- require Carp;
- Carp::croak("Weak references are not implemented in this version of perl");
- }
-
if (grep { /^isvstring$/ } @_ ) {
require Carp;
Carp::croak("Vstrings are not implemented in this version of perl");
}
- if (grep { /^isbool$/ } @_ ) {
- require Carp;
- Carp::croak("isbool is not implemented in this version of perl");
- }
-
@_;
}
@@ -224,16 +201,6 @@ B<NOTE>: Copying a weak reference creates a normal, strong, reference.
=head1 OTHER FUNCTIONS
-=head2 isbool
-
- my $bool = isbool( $var );
-
-I<Available only since perl 5.35.3 onwards.>
-
-Returns true if the given variable is boolean in nature - that is, it is the
-result of a boolean operator (such as C<defined>, C<exists>, or a numerical or
-string comparison), or is a variable that is copied from one.
-
=head2 dualvar
my $var = dualvar( $num, $string );
@@ -258,24 +225,24 @@ true.
$dual = isdual($foo); # true
Note that a scalar can be made to have both string and numeric content through
-numeric operations:
+standard operations:
$foo = "10";
$dual = isdual($foo); # false
$bar = $foo + 0;
$dual = isdual($foo); # true
-Note that although C<$!> appears to be a dual-valued variable, it is
-actually implemented as a magical variable inside the interpreter:
+The C<$!> variable is commonly dual-valued, though it is also magical in other
+ways:
$! = 1;
+ $dual = isdual($!); # true
print("$!\n"); # "Operation not permitted"
- $dual = isdual($!); # false
-You can capture its numeric and string content using:
-
- $err = dualvar $!, $!;
- $dual = isdual($err); # true
+B<CAUTION>: This function is not as useful as it may seem. Dualvars are not a
+distinct concept in Perl, but a standard internal construct of all scalar
+values. Almost any value could be considered as a dualvar by this function
+through the course of normal operations.
=head2 isvstring
@@ -341,21 +308,11 @@ Module use may give one of the following errors during import.
=over
-=item Weak references are not implemented in this version of perl
-
-The version of perl that you are using does not implement weak references, to
-use L</isweak> or L</weaken> you will need to use a newer release of perl.
-
=item Vstrings are not implemented in this version of perl
The version of perl that you are using does not implement Vstrings, to use
L</isvstring> you will need to use a newer release of perl.
-=item isbool is not implemented in this version of perl
-
-The version of perl that you are using does not implement stable boolean
-tracking, to use L</isbool> you will need to use a newer release of perl.
-
=back
=head1 KNOWN BUGS
diff --git a/cpan/Scalar-List-Utils/lib/Sub/Util.pm b/cpan/Scalar-List-Utils/lib/Sub/Util.pm
index 8b25af7544..eb4f928960 100644
--- a/cpan/Scalar-List-Utils/lib/Sub/Util.pm
+++ b/cpan/Scalar-List-Utils/lib/Sub/Util.pm
@@ -15,7 +15,7 @@ our @EXPORT_OK = qw(
subname set_subname
);
-our $VERSION = "1.56_001";
+our $VERSION = "1.60";
$VERSION =~ tr/_//d;
require List::Util; # as it has the XS
diff --git a/cpan/Scalar-List-Utils/t/boolean-thr.t b/cpan/Scalar-List-Utils/t/boolean-thr.t
deleted file mode 100644
index 4b4073948c..0000000000
--- a/cpan/Scalar-List-Utils/t/boolean-thr.t
+++ /dev/null
@@ -1,38 +0,0 @@
-#!./perl
-
-use strict;
-use warnings;
-
-use Config ();
-use Scalar::Util ();
-use Test::More
- (grep { /isbool/ } @Scalar::Util::EXPORT_FAIL) ? (skip_all => 'isbool is not supported on this perl') :
- (!$Config::Config{usethreads}) ? (skip_all => 'perl does not support threads') :
- (tests => 5);
-
-use threads;
-use threads::shared;
-
-Scalar::Util->import("isbool");
-
-ok(threads->create( sub { isbool($_[0]) }, !!0 )->join,
- 'value in to thread is bool');
-
-ok(isbool(threads->create( sub { return !!0 } )->join),
- 'value out of thread is bool');
-
-{
- my $var = !!0;
- ok(threads->create( sub { isbool($var) } )->join,
- 'variable captured by thread is bool');
-}
-
-{
- my $sharedvar :shared = !!0;
-
- ok(isbool($sharedvar),
- ':shared variable is bool outside');
-
- ok(threads->create( sub { isbool($sharedvar) } )->join,
- ':shared variable is bool inside thread');
-}
diff --git a/cpan/Scalar-List-Utils/t/boolean.t b/cpan/Scalar-List-Utils/t/boolean.t
deleted file mode 100644
index f543fa450c..0000000000
--- a/cpan/Scalar-List-Utils/t/boolean.t
+++ /dev/null
@@ -1,64 +0,0 @@
-#!./perl
-
-use strict;
-use warnings;
-
-use Scalar::Util ();
-use Test::More (grep { /isbool/ } @Scalar::Util::EXPORT_FAIL)
- ? (skip_all => 'isbool is not supported on this perl')
- : (tests => 15);
-
-Scalar::Util->import("isbool");
-
-# basic constants
-{
- ok(isbool(!!0), 'false is boolean');
- ok(isbool(!!1), 'true is boolean');
-
- ok(!isbool(0), '0 is not boolean');
- ok(!isbool(1), '1 is not boolean');
- ok(!isbool(""), '"" is not boolean');
-}
-
-# variables
-{
- my $falsevar = !!0;
- my $truevar = !!1;
-
- ok(isbool($falsevar), 'false var is boolean');
- ok(isbool($truevar), 'true var is boolean');
-
- my $str = "$truevar";
- my $num = $truevar + 0;
-
- ok(!isbool($str), 'stringified true is not boolean');
- ok(!isbool($num), 'numified true is not boolean');
-
- ok(isbool($truevar), 'true var remains boolean after stringification and numification');
-}
-
-# aggregate members
-{
- my %hash = ( false => !!0, true => !!1 );
-
- ok(isbool($hash{false}), 'false HELEM is boolean');
- ok(isbool($hash{true}), 'true HELEM is boolean');
-
- # We won't test AELEM but it's likely to be the same
-}
-
-{
- my $var;
- package Foo { sub TIESCALAR { bless {}, shift } sub FETCH { $var } }
-
- tie my $tied, "Foo";
-
- $var = 1;
- ok(!isbool($tied), 'tied var should not yet be boolean');
-
- $var = !!1;
- ok(isbool($tied), 'tied var should now be boolean');
-
- my $copy = $tied;
- ok(isbool($copy), 'copy of tied var should also be boolean');
-}
diff --git a/cpan/Scalar-List-Utils/t/dualvar.t b/cpan/Scalar-List-Utils/t/dualvar.t
index bd77c969b5..e452749f01 100644
--- a/cpan/Scalar-List-Utils/t/dualvar.t
+++ b/cpan/Scalar-List-Utils/t/dualvar.t
@@ -3,15 +3,10 @@
use strict;
use warnings;
-use Scalar::Util ();
-use Test::More (grep { /dualvar/ } @Scalar::Util::EXPORT_FAIL)
- ? (skip_all => 'dualvar requires XS version')
- : (tests => 41);
+use Scalar::Util qw(dualvar isdual);
+use Test::More tests => 41;
use Config;
-Scalar::Util->import('dualvar');
-Scalar::Util->import('isdual');
-
my $var;
$var = dualvar( 2.2,"string");
diff --git a/cpan/Scalar-List-Utils/t/first.t b/cpan/Scalar-List-Utils/t/first.t
index 3f008e703c..07b7ec24dc 100644
--- a/cpan/Scalar-List-Utils/t/first.t
+++ b/cpan/Scalar-List-Utils/t/first.t
@@ -90,7 +90,7 @@ SKIP: {
}
# These tests are only relevant for the real multicall implementation. The
-# psuedo-multicall implementation behaves differently.
+# pseudo-multicall implementation behaves differently.
SKIP: {
$List::Util::REAL_MULTICALL ||= 0; # Avoid use only once
skip("Poor man's MULTICALL can't cope", 2)
diff --git a/cpan/Scalar-List-Utils/t/isvstring.t b/cpan/Scalar-List-Utils/t/isvstring.t
index 3649d41c59..e613a6e257 100644
--- a/cpan/Scalar-List-Utils/t/isvstring.t
+++ b/cpan/Scalar-List-Utils/t/isvstring.t
@@ -6,10 +6,10 @@ use warnings;
$|=1;
use Scalar::Util ();
use Test::More (grep { /isvstring/ } @Scalar::Util::EXPORT_FAIL)
- ? (skip_all => 'isvstring requires XS version')
+ ? (skip_all => 'isvstring is not supported on this perl version')
: (tests => 3);
-Scalar::Util->import(qw[isvstring]);
+use Scalar::Util qw(isvstring);
my $vs = ord("A") == 193 ? 241.75.240 : 49.46.48;
diff --git a/cpan/Scalar-List-Utils/t/pair.t b/cpan/Scalar-List-Utils/t/pair.t
index 7d7a6a9bb5..27e836454b 100644
--- a/cpan/Scalar-List-Utils/t/pair.t
+++ b/cpan/Scalar-List-Utils/t/pair.t
@@ -5,7 +5,6 @@ use warnings;
use Test::More tests => 29;
use List::Util qw(pairgrep pairfirst pairmap pairs unpairs pairkeys pairvalues);
-use Scalar::Util qw(blessed);
no warnings 'misc'; # avoid "Odd number of elements" warnings most of the time
@@ -108,7 +107,7 @@ is_deeply( [ pairs one => 1, two => ],
is_deeply( $p[0]->TO_JSON,
[ one => 1 ],
'pairs ->TO_JSON' );
- ok( !blessed($p[0]->TO_JSON) , 'pairs ->TO_JSON is not blessed' );
+ is( ref($p[0]->TO_JSON), 'ARRAY', 'pairs ->TO_JSON is not blessed' );
}
is_deeply( [ unpairs [ four => 4 ], [ five => 5 ], [ six => 6 ] ],
diff --git a/cpan/Scalar-List-Utils/t/product.t b/cpan/Scalar-List-Utils/t/product.t
index 87e887cf88..3ff5ae0f13 100644
--- a/cpan/Scalar-List-Utils/t/product.t
+++ b/cpan/Scalar-List-Utils/t/product.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 25;
+use Test::More tests => 27;
use Config;
use List::Util qw(product);
@@ -32,6 +32,13 @@ is( $v, 0, '1 * 0');
$v = product(0, 0);
is( $v, 0, 'two 0');
+# RT139601 cornercases
+{
+ # Numify the result because some older perl versions see "-0" as a string
+ is( 0+product(-1.0, 0), 0, 'product(-1.0, 0)' );
+ is( 0+product(-1, 0), 0, 'product(-1, 0)' );
+}
+
my $x = -3;
$v = product($x, 3);
diff --git a/cpan/Scalar-List-Utils/t/reduce.t b/cpan/Scalar-List-Utils/t/reduce.t
index 67fdbaac22..6e90ffba01 100644
--- a/cpan/Scalar-List-Utils/t/reduce.t
+++ b/cpan/Scalar-List-Utils/t/reduce.t
@@ -126,7 +126,7 @@ SKIP: {
}
# These tests are only relevant for the real multicall implementation. The
-# psuedo-multicall implementation behaves differently.
+# pseudo-multicall implementation behaves differently.
SKIP: {
$List::Util::REAL_MULTICALL ||= 0; # Avoid use only once
skip("Poor man's MULTICALL can't cope", 2)
diff --git a/cpan/Scalar-List-Utils/t/reductions.t b/cpan/Scalar-List-Utils/t/reductions.t
index fd669f14c7..d7144d13d8 100644
--- a/cpan/Scalar-List-Utils/t/reductions.t
+++ b/cpan/Scalar-List-Utils/t/reductions.t
@@ -8,7 +8,7 @@ use Test::More tests => 7;
use List::Util qw( reductions );
is_deeply( [ reductions { } ], [],
- 'emmpty list'
+ 'empty list'
);
is_deeply(
diff --git a/cpan/Scalar-List-Utils/t/undefined-block.t b/cpan/Scalar-List-Utils/t/undefined-block.t
new file mode 100644
index 0000000000..36119ea0b6
--- /dev/null
+++ b/cpan/Scalar-List-Utils/t/undefined-block.t
@@ -0,0 +1,18 @@
+#!./perl
+
+use strict;
+use warnings;
+
+my @subs;
+BEGIN { @subs = qw(reduce first none all any notall pairfirst pairgrep pairmap) };
+use List::Util @subs;
+use Test::More;
+plan tests => @subs * 2;
+
+for my $sub (@subs) {
+ eval { no strict 'refs'; no warnings 'uninitialized'; &{$sub}(undef, 1, 2) };
+ like($@, qr{^Not a subroutine reference}, "$sub(undef, ...) croaks");
+
+ eval { no strict 'refs'; &{$sub}(\&undefined, 1, 2) };
+ like($@, qr{^Undefined subroutine in $sub}, "$sub(\&undefined, ...) croaks");
+}
diff --git a/cpan/Scalar-List-Utils/t/weak.t b/cpan/Scalar-List-Utils/t/weak.t
index 39a4167cd6..90bf469f29 100644
--- a/cpan/Scalar-List-Utils/t/weak.t
+++ b/cpan/Scalar-List-Utils/t/weak.t
@@ -5,12 +5,8 @@ use warnings;
use Config;
-use Scalar::Util ();
-use Test::More ((grep { /weaken/ } @Scalar::Util::EXPORT_FAIL) and !$ENV{PERL_CORE})
- ? (skip_all => 'weaken requires XS version')
- : (tests => 28);
-
-Scalar::Util->import(qw(weaken unweaken isweak));
+use Scalar::Util qw(weaken unweaken isweak);
+use Test::More tests => 28;
# two references, one is weakened, the other is then undef'ed.
{