1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
# perl
#$Id$
# 01_oo_lists_dual_reg_sorted.t
use strict;
use Test::More tests => 30;
use List::Compare;
use lib ("./t");
use Test::ListCompareSpecial qw( :seen :wrap :arrays :hashes :results );
use IO::CaptureOutput qw( capture );
my @pred = ();
my %seen = ();
my %pred = ();
my @unpred = ();
my (@unique, @complement, @intersection, @union, @symmetric_difference, @bag);
my ($unique_ref, $complement_ref, $intersection_ref, $union_ref,
$symmetric_difference_ref, $bag_ref);
my ($LR, $RL, $eqv, $disj, $return, $vers);
my (@nonintersection, @shared);
my ($nonintersection_ref, $shared_ref);
my ($memb_hash_ref, $memb_arr_ref, @memb_arr);
my ($unique_all_ref, $complement_all_ref);
my @args;
my ($lc, $lca);
my %h10 = (
abel => 2, baker => 1, camera => 1, delta => 1, edward => 1, fargo => 1,
golfer => q{one},
);
my %h11 = (
baker => 1, camera => 1, delta => 2, edward => 1, fargo => 1, golfer => 1,
hilton => 1,
);
my %h12 = (
fargo => 1, golfer => 1, hilton => 1, icon => 2, jerky => 1,
);
eval { $lc = List::Compare->new(\%h10, \%h11); };
like($@,
qr/Values in a 'seen-hash' may only be positive integers/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/First hash in arguments/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+golfer\s+Value:\s+one/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
eval { $lc = List::Compare->new('-a', \%h10, \%h11); };
like($@,
qr/Values in a 'seen-hash' must be numeric/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/First hash in arguments/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+golfer\s+Value:\s+one/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
eval { $lc = List::Compare->new(\%h10, \%h11, \%h12); };
like($@,
qr/Values in a 'seen-hash' must be positive integers/s,
"Got expected error message for hash which was not a seen-hash"
);
like($@,
qr/Hash\s+0/s,
"Got expected error message for hash which was not a seen-hash"
);
like($@,
qr/Bad key-value pair:\s+golfer\s+one/s,
"Got expected error message for hash which was not a seen-hash"
);
my %h20 = (
abel => 2, baker => 1, camera => 1, delta => 1, edward => 1, fargo => 1,
golfer => 1,
);
my %h21 = (
baker => 1, camera => 1, delta => 2, edward => 1, fargo => 1, golfer => 1,
hilton => q{one},
);
eval { $lc = List::Compare->new(\%h20, \%h21); };
like($@,
qr/Values in a 'seen-hash' may only be positive integers/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Second hash in arguments/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+hilton\s+Value:\s+one/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
eval { $lc = List::Compare->new('-a', \%h20, \%h21); };
like($@,
qr/Values in a 'seen-hash' must be numeric/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Second hash in arguments/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+hilton\s+Value:\s+one/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
my %h30 = (
abel => 2, baker => 1, camera => 1, delta => 1, edward => 1, fargo => 1,
golfer => 0,
);
my %h31 = (
baker => 1, camera => 1, delta => 2, edward => 1, fargo => 1, golfer => 1,
hilton => 1,
);
eval { $lc = List::Compare->new(\%h30, \%h31); };
like($@,
qr/Values in a 'seen-hash' may only be positive integers/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/First hash in arguments/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+golfer\s+Value:\s+0/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
eval { $lc = List::Compare->new('-a', \%h30, \%h31); };
like($@,
qr/Values in a 'seen-hash' must be numeric/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/First hash in arguments/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+golfer\s+Value:\s+0/s,
"Got expected error message for left-hand hash which was not a seen-hash"
);
eval { $lc = List::Compare->new(\%h30, \%h31, \%h12); };
like($@,
qr/Values in a 'seen-hash' must be positive integers/s,
"Got expected error message for hash which was not a seen-hash"
);
like($@,
qr/Hash\s+0/s,
"Got expected error message for hash which was not a seen-hash"
);
like($@,
qr/Bad key-value pair:\s+golfer\s+0/s,
"Got expected error message for hash which was not a seen-hash"
);
my %h40 = (
abel => 2, baker => 1, camera => 1, delta => 1, edward => 1, fargo => 1,
golfer => 1,
);
my %h41 = (
baker => 1, camera => 1, delta => 2, edward => 1, fargo => 1, golfer => 1,
hilton => 0,
);
eval { $lc = List::Compare->new(\%h40, \%h41); };
like($@,
qr/Values in a 'seen-hash' may only be positive integers/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Second hash in arguments/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+hilton\s+Value:\s+0/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
eval { $lc = List::Compare->new('-a', \%h40, \%h41); };
like($@,
qr/Values in a 'seen-hash' must be numeric/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Second hash in arguments/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
like($@,
qr/Key:\s+hilton\s+Value:\s+0/s,
"Got expected error message for right-hand hash which was not a seen-hash"
);
|