|
1 | 1 | use v6;
|
2 | 2 | use Test;
|
3 | 3 |
|
4 |
| -plan 88; |
| 4 | +plan 164; |
5 | 5 |
|
6 | 6 | sub showset($s) { $s.keys.sort.join(' ') }
|
7 | 7 |
|
@@ -124,4 +124,119 @@ isa_ok ($s (&) $kb), Set, "... and it's actually a Set (texas)";
|
124 | 124 | is showset($kb (&) <glad green bread>), showset(set <glad bread>), "KeyBag intersection with array of strings works (texas)";
|
125 | 125 | isa_ok ($kb (&) <glad green bread>), Set, "... and it's actually a Set (texas)";
|
126 | 126 |
|
| 127 | +# set subtraction |
| 128 | + |
| 129 | +is showset($s (-) $s), showset(∅), "Set subtracted from Set is correct"; |
| 130 | +isa_ok ($s (-) $s), Set, "... and it's actually a Set"; |
| 131 | + |
| 132 | +is showset($s (-) $ks), showset(set <isn't your day>), "KeySet subtracted from Set is correct"; |
| 133 | +isa_ok ($s (-) $ks), Set, "... and it's actually a Set"; |
| 134 | +is showset($ks (-) $s), showset(set <is>), "Set subtracted from KeySet is correct"; |
| 135 | +isa_ok ($ks (-) $s), Set, "... and it's actually a Set"; |
| 136 | + |
| 137 | +is showset($b (-) $s), showset($b), "Set subtracted from Bag is correct"; |
| 138 | +isa_ok ($b (-) $s), Set, "... and it's actually a Set"; |
| 139 | +is showset($s (-) $b), showset($s), "Bag subtracted from Set is correct"; |
| 140 | +isa_ok ($s (-) $b), Set, "... and it's actually a Set"; |
| 141 | + |
| 142 | +is showset($s (-) $kb), showset(set <I'm afraid it isn't day>), "KeyBag subtracted from Set is correct"; |
| 143 | +isa_ok ($s (-) $kb), Set, "... and it's actually a Set"; |
| 144 | +is showset($kb (-) $s), showset(set <Come, take bread with joy, and wine with a glad heart>), "Set subtracted from KeyBag is correct"; |
| 145 | +isa_ok ($kb (-) $s), Set, "... and it's actually a Set"; |
| 146 | + |
| 147 | +# symmetric difference |
| 148 | + |
| 149 | +is showset($s (^) $s), showset(∅), "Set symmetric difference with Set is correct"; |
| 150 | +isa_ok ($s (^) $s), Set, "... and it's actually a Set"; |
| 151 | + |
| 152 | +is showset($s (^) $ks), showset(set <is isn't your day>), "KeySet symmetric difference with Set is correct"; |
| 153 | +isa_ok ($s (^) $ks), Set, "... and it's actually a Set"; |
| 154 | +is showset($ks (^) $s), showset(set <is isn't your day>), "Set symmetric difference with KeySet is correct"; |
| 155 | +isa_ok ($ks (^) $s), Set, "... and it's actually a Set"; |
| 156 | + |
| 157 | +is showset($s (^) $b), showset(set($s, $b)), "Bag symmetric difference with Set is correct"; |
| 158 | +isa_ok ($s (^) $b), Set, "... and it's actually a Set"; |
| 159 | +is showset($b (^) $s), showset(set($s, $b)), "Set symmetric difference with Bag is correct"; |
| 160 | +isa_ok ($b (^) $s), Set, "... and it's actually a Set"; |
| 161 | + |
| 162 | +is showset($s (^) $kb), showset(set($s, $kb) (-) set <your>), "KeyBag subtracted from Set is correct"; |
| 163 | +isa_ok ($s (^) $kb), Set, "... and it's actually a Set"; |
| 164 | +is showset($kb (^) $s), showset(set($s, $kb) (-) set <your>), "Set subtracted from KeyBag is correct"; |
| 165 | +isa_ok ($kb (^) $s), Set, "... and it's actually a Set"; |
| 166 | + |
| 167 | +# is subset of |
| 168 | + |
| 169 | +ok <your day> ⊆ $s, "'Your day' is subset of Set"; |
| 170 | +ok $s ⊆ $s, "Set is subset of itself"; |
| 171 | +ok $s ⊆ <I'm afraid it isn't your day old chum>, "Set is subset of string"; |
| 172 | + |
| 173 | +ok ($ks (-) set <is>) ⊆ $ks, "Set is subset of KeySet"; |
| 174 | +ok $ks ⊆ $ks, "KeySet is subset of itself"; |
| 175 | +ok $ks ⊆ <I'm afraid it is my day>, "KeySet is subset of string"; |
| 176 | + |
| 177 | +nok $s ⊆ $b, "Set is not a subset of Bag"; |
| 178 | +ok $b ⊆ $b, "Bag is subset of itself"; |
| 179 | +nok $b ⊆ $s, "Bag is not a subset of Set"; |
| 180 | + |
| 181 | +nok $s ⊆ $kb, "Set is not a subset of KeyBag"; |
| 182 | +ok $kb ⊆ $kb, "KeyBag is subset of itself"; |
| 183 | +nok $kb ⊆ $s, "KeyBag is not a subset of Set"; |
| 184 | + |
| 185 | +ok <your day> (<=) $s, "'Your day' is subset of Set"; |
| 186 | +ok $s (<=) $s, "Set is subset of itself"; |
| 187 | +ok $s (<=) <I'm afraid it isn't your day old chum>, "Set is subset of string"; |
| 188 | + |
| 189 | +ok ($ks (-) set <is>) (<=) $ks, "Set is subset of KeySet (texas)"; |
| 190 | +ok $ks (<=) $ks, "KeySet is subset of itself (texas)"; |
| 191 | +ok $ks (<=) <I'm afraid it is my day>, "KeySet is subset of string (texas)"; |
| 192 | + |
| 193 | +nok $s (<=) $b, "Set is not a subset of Bag (texas)"; |
| 194 | +ok $b (<=) $b, "Bag is subset of itself (texas)"; |
| 195 | +nok $b (<=) $s, "Bag is not a subset of Set (texas)"; |
| 196 | + |
| 197 | +nok $s (<=) $kb, "Set is not a subset of KeyBag (texas)"; |
| 198 | +ok $kb (<=) $kb, "KeyBag is subset of itself (texas)"; |
| 199 | +nok $kb (<=) $s, "KeyBag is not a subset of Set (texas)"; |
| 200 | + |
| 201 | +# is not a subset of |
| 202 | + |
| 203 | +nok <your day> ⊈ $s, "'Your day' is subset of Set"; |
| 204 | +nok $s ⊈ $s, "Set is subset of itself"; |
| 205 | +nok $s ⊈ <I'm afraid it isn't your day old chum>, "Set is subset of string"; |
| 206 | + |
| 207 | +nok ($ks (-) set <is>) ⊈ $ks, "Set is subset of KeySet"; |
| 208 | +nok $ks ⊈ $ks, "KeySet is subset of itself"; |
| 209 | +nok $ks ⊈ <I'm afraid it is my day>, "KeySet is subset of string"; |
| 210 | + |
| 211 | +ok $s ⊈ $b, "Set is not a subset of Bag"; |
| 212 | +nok $b ⊈ $b, "Bag is subset of itself"; |
| 213 | +ok $b ⊈ $s, "Bag is not a subset of Set"; |
| 214 | + |
| 215 | +ok $s ⊈ $kb, "Set is not a subset of KeyBag"; |
| 216 | +nok $kb ⊈ $kb, "KeyBag is subset of itself"; |
| 217 | +ok $kb ⊈ $s, "KeyBag is not a subset of Set"; |
| 218 | + |
| 219 | +nok <your day> !(<=) $s, "'Your day' is subset of Set (texas)"; |
| 220 | +nok $s !(<=) $s, "Set is subset of itself (texas)"; |
| 221 | +nok $s !(<=) <I'm afraid it isn't your day old chum>, "Set is subset of string (texas)"; |
| 222 | + |
| 223 | +nok ($ks (-) set <is>) !(<=) $ks, "Set is subset of KeySet (texas)"; |
| 224 | +nok $ks !(<=) $ks, "KeySet is subset of itself (texas)"; |
| 225 | +nok $ks !(<=) <I'm afraid it is my day>, "KeySet is subset of string (texas)"; |
| 226 | + |
| 227 | +ok $s !(<=) $b, "Set is not a subset of Bag (texas)"; |
| 228 | +nok $b !(<=) $b, "Bag is subset of itself (texas)"; |
| 229 | +ok $b !(<=) $s, "Bag is not a subset of Set (texas)"; |
| 230 | + |
| 231 | +ok $s !(<=) $kb, "Set is not a subset of KeyBag (texas)"; |
| 232 | +nok $kb !(<=) $kb, "KeyBag is subset of itself (texas)"; |
| 233 | +ok $kb !(<=) $s, "KeyBag is not a subset of Set (texas)"; |
| 234 | + |
| 235 | +# my $s = set <I'm afraid it isn't your day>; |
| 236 | +# my $ks = KeySet.new(<I'm afraid it is>); # Tom Stoppard |
| 237 | +# my $b = bag <Whoever remains for long here in this earthly life will enjoy and endure more than enough>; # Seamus Heaney |
| 238 | +# my $kb = KeyBag.new(<Come, take your bread with joy, and your wine with a glad heart>); # Ecclesiastes 9:7 |
| 239 | + |
| 240 | + |
| 241 | + |
127 | 242 | # vim: ft=perl6
|
0 commit comments