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/?a=commitdiff_plain;h=ae9a21ef5300b492faf20fa5b98340b7783ca098;p=perl%2Fmodules%2FSub-Nary.git scale() shouldn't fill {} --- diff --git a/Nary.xs b/Nary.xs index 66eced6..a64d619 100644 --- a/Nary.xs +++ b/Nary.xs @@ -147,7 +147,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 42847e6..5453dbf 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');