1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as `perl test.pl'
3
4######################### We start with some black magic to print on failure.
5
6# Change 1..1 below to 1..last_test_to_print .
7# (It may become useful if the test is moved to ./t subdirectory.)
8
9BEGIN { $| = 1; print "1..10\n"; }
10END {print "not ok 1\n" unless $loaded;}
11use Tie::Hash::TwoWay;
12$loaded = 1;
13print "ok 1\n";
14
15######################### End of black magic.
16
17# Insert your test code below (better if it prints "ok 13"
18# (correspondingly "not ok 13") depending on the success of chunk 13
19# of the test code):
20
21tie %hash, 'Tie::Hash::TwoWay';
22
23my %list = (
24	    one => [1, 2, 3],
25	    two => [4, 5, 2],
26	   );
27
28$hash{one} = $list{one};
29$hash{two} = $list{two};
30$hash{single} = 'scalar';
31
32print "not " unless exists $hash{1};
33print "ok 2\n";
34print "not " unless exists $hash{2}->{one};
35print "ok 3\n";
36print "not " unless exists $hash{2}->{two};
37print "ok 4\n";
38print "not " unless exists $hash{one}->{3};
39print "ok 5\n";
40print "not " unless exists $hash{scalar};
41print "ok 6\n";
42delete $hash{one};
43
44print "not " if exists $hash{1};
45print "ok 7\n";
46print "not " if exists $hash{2}->{one};
47print "ok 8\n";
48
49# test secondary keys
50my $secondary = scalar %hash;
51print "not " unless scalar keys %$secondary == 4;
52print "ok 9\n";
53
54# this should clear the whole hash
55delete $hash{2};
56delete $hash{4};
57delete $hash{5};
58delete $hash{'scalar'};
59
60print "not " if scalar keys %hash;
61print "ok 10\n";
62