From: Vincent Pit Date: Thu, 21 Aug 2008 10:52:25 +0000 (+0200) Subject: scale() shouldn't fill {} X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Nary.git;a=commitdiff_plain;h=3a17f1185ab1189e5e5cb87294974305467d2bec scale() shouldn't fill {} --- diff --git a/Nary.xs b/Nary.xs index 285bfc3..dc8e089 100644 --- a/Nary.xs +++ b/Nary.xs @@ -140,7 +140,7 @@ CODE: } else { hv = (HV *) SvRV(sv); if (!hv_iterinit(hv)) { - sn_store(res, "0", 1, newSVnv(c), 0); + XSRETURN_UNDEF; } else { hv_iterinit(hv); while (key = hv_iternext(hv)) { diff --git a/t/15-misc-xs.t b/t/15-misc-xs.t index c9ac01d..7cc9404 100644 --- a/t/15-misc-xs.t +++ b/t/15-misc-xs.t @@ -23,8 +23,8 @@ is_deeply(normalize({ list => 1, 2 => 2, 3 => 1 }), *scale = *Sub::Nary::scale{CODE}; -is_deeply(scale(1, {}), { 0 => 1 }, 'scale 1, empty-ref'); -is_deeply(scale(0.5, {}), { 0 => 0.5 }, 'scale 0.5, empty-ref'); +is_deeply(scale(1, {}), undef, 'scale 1, empty-ref'); +is_deeply(scale(0.5, {}), undef, 'scale 0.5, empty-ref'); is_deeply(scale(0.5, { list => 2 }), { list => 1 }, 'scale 0.5, list'); is_deeply(scale(0.5, { list => 2, 1 => 2 }), { list => 1, 1 => 1 }, 'scale 0.5, list/const');