X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F15-misc-xs.t;h=5453dbf008375003a1c864144d1cf943ab3a8bc8;hb=2eb7d799fbc08f3dbeada52aeac89c781983e081;hp=c9ac01dedd22c2ffd13620aec8fad8cdd6d3c8dd;hpb=d625b2c0b187b0a423dfdcf5d96d783555bcc560;p=perl%2Fmodules%2FSub-Nary.git diff --git a/t/15-misc-xs.t b/t/15-misc-xs.t index c9ac01d..5453dbf 100644 --- a/t/15-misc-xs.t +++ b/t/15-misc-xs.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 20; use Sub::Nary; @@ -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'); @@ -47,26 +47,3 @@ is_deeply(cumulate({ 1 => 0.5, 2 => 0.5 }, 1, 0.5), { 1 => 0.5, 2 => 0.5 }, 'cumulate ref, 1, frac'); is_deeply(cumulate({ 1 => 0.5, 2 => 0.5 }, 2, 0.5), { 1 => 0.75, 2 => 0.75 }, 'cumulate ref, 1, frac'); - -*combine = *Sub::Nary::combine{CODE}; - -is_deeply(combine(undef), undef, 'combine undef'); -is_deeply(combine({}), {}, 'combine empty-ref'); -is_deeply(combine({}, {}), {}, 'combine empty-ref, empty-ref'); -is_deeply(combine(1), { 1 => 1 }, 'combine const'); -is_deeply(combine(1, 2), { 3 => 1 }, 'combine const, const'); -is_deeply(combine(1, 'list'), { 'list' => 1 }, 'combine const, list'); -is_deeply(combine(1,{'list'=>1}), { 'list' => 1 }, 'combine const, list'); -is_deeply(combine(1, { 1 => 0.5, 2 => 0.5 }), { 2 => 0.5, 3 => 0.5 }, - 'combine const, hashref'); -is_deeply(combine(1, { 1 => 0.5, 'list' => 0.5 }), { 2 => 0.5, 'list' => 0.5 }, - 'combine const, hashref with list'); -my $x = { 1 => 0.5, 2 => 0.5 }; -is_deeply(combine($x, $x), { 2 => 0.25, 3 => 0.5, 4 => 0.25 }, - 'combine hashref, hashref'); -is_deeply(combine($x, 'list', $x), { list => 1 }, - 'combine hashref, list, hashref'); -$x = { 1 => 0.5, list => 0.5 }; -is_deeply(combine($x, $x), { 2 => 0.25, list => 0.75 }, - 'combine hashref with list, hashref with list'); -