14 require Tie::SubstrHash;
18 tie %a, 'Tie::SubstrHash', 3, 3, 3;
23 print "not " unless $a{abc} == 123;
26 print "not " unless keys %a == 2;
31 print "not " unless $a{bcd} == 234;
34 print "not " unless (values %a)[0] == 234;
37 eval { $a{abcd} = 123 };
38 print "not " unless $@ =~ /Key "abcd" is not 3 characters long/;
41 eval { $a{abc} = 1234 };
42 print "not " unless $@ =~ /Value "1234" is not 3 characters long/;
45 eval { $a = $a{abcd}; $a++ };
46 print "not " unless $@ =~ /Key "abcd" is not 3 characters long/;
49 @a{qw(abc cde)} = qw(123 345);
51 print "not " unless $a{cde} == 345;
54 eval { $a{def} = 456 };
55 print "not " unless $@ =~ /Table is full \(3 elements\)/;
60 print "not " unless keys %a == 0;
63 # Tests 11..16 by Linc Madison.
65 my $hashsize = 119; # arbitrary values from my data
67 tie %test, "Tie::SubstrHash", 13, 86, $hashsize;
69 for (my $i = 1; $i <= $hashsize; $i++) {
70 my $key1 = $i + 100_000; # fix to uniform 6-digit numbers
71 my $key2 = "abcdefg$key1";
72 $test{$key2} = ("abcdefgh" x 10) . "$key1";
75 for (my $i = 1; $i <= $hashsize; $i++) {
76 my $key1 = $i + 100_000;
77 my $key2 = "abcdefg$key1";
78 unless ($test{$key2}) {
85 print "not " unless Tie::SubstrHash::findgteprime(1) == 2;
88 print "not " unless Tie::SubstrHash::findgteprime(2) == 2;
91 print "not " unless Tie::SubstrHash::findgteprime(5.5) == 7;
94 print "not " unless Tie::SubstrHash::findgteprime(13) == 13;
97 print "not " unless Tie::SubstrHash::findgteprime(13.000001) == 17;
100 print "not " unless Tie::SubstrHash::findgteprime(114) == 127;
103 print "not " unless Tie::SubstrHash::findgteprime(1000) == 1009;
106 print "not " unless Tie::SubstrHash::findgteprime(1024) == 1031;
109 print "not " unless Tie::SubstrHash::findgteprime(10000) == 10007;