1# -*- Mode: CPerl -*- 2 3use strict; 4use warnings; 5 6use Test::More 'no_plan'; 7 8use Hash::MultiKey; 9 10tie my (%hmk), 'Hash::MultiKey'; 11 12my @mk = (["foo"], 13 ["foo", "bar", "baz"], 14 ["foo", "bar", "baz", "zoo"], 15 ["goo"], 16 ["goo", "car", "caz"], 17 ["goo", "car", "caz", "aoo"],); 18 19my @v = (undef, 20 1, 21 'string', 22 ['array', 'ref'], 23 {hash => 'ref', with => 'three', keys => undef}, 24 \7,); 25 26# initialize %hmk 27$hmk{[join $;, @{$mk[$_]}]} = $v[$_] foreach 0..$#mk; 28 29# positive exists 30ok(exists $hmk{[join $;, @{$mk[$_]}]}, "exists key $_") foreach 0..$#mk; 31 32# negative exists 33my @nmk = (["hoo"], # beginning 34 ["foo", "bar"], # intermediate 35 ["foo", "bar", "baz", "zoo", "none here"],); # end 36 37ok(!exists $hmk{[join $;, @{$nmk[$_]}]}, "! exists key $_") foreach 0..$#nmk; 38