Skip to content

Commit 4dfee69

Browse files
committed
Add tests for empty Set(|Hash).pick handling
1 parent c4c10d5 commit 4dfee69

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

S02-types/set.t

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use v6;
22
use Test;
33

4-
plan 189;
4+
plan 197;
55

66
sub showset($s) { $s.keys.sort.join(' ') }
77

@@ -283,6 +283,22 @@ dies-ok { set(1, 2) «+» set(3, 4) }, 'Set «+» Set is illegal';
283283
is $s.total, 3, '.pick should not change Set';
284284
}
285285

286+
# empty set handling of .pick
287+
{
288+
is-deeply set().pick, Nil, 'empty set.pick -> Nil';
289+
for
290+
1, '1',
291+
*-1, '*-1',
292+
*, '*',
293+
Inf, 'Inf',
294+
-1, '-1',
295+
-Inf, '-Inf'
296+
-> $p, $t {
297+
is-deeply set().pick($p), ().Seq, "empty set.rpick($t) -> ().Seq"
298+
}
299+
dies-ok { set().pick(NaN) }, 'empty set.pick(NaN) should die';
300+
}
301+
286302
# L<S32::Containers/Set/grab>
287303

288304
{

S02-types/sethash.t

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use v6;
22
use Test;
33

4-
plan 229;
4+
plan 237;
55

66
# L<S02/Mutable types/"QuantHash of Bool">
77

@@ -296,6 +296,22 @@ sub showset($s) { $s.keys.sort.join(' ') }
296296
is $s.elems, 3, '.pick should not change the SetHash';
297297
}
298298

299+
# empty SetHash handling of .pick
300+
{
301+
is-deeply ().SetHash.pick, Nil, '().SetHash.pick -> Nil';
302+
for
303+
1, '1',
304+
*-1, '*-1',
305+
*, '*',
306+
Inf, 'Inf',
307+
-1, '-1',
308+
-Inf, '-Inf'
309+
-> $p, $t {
310+
is-deeply ().SetHash.pick($p), ().Seq, "().SetHash.pick($t) -> ().Seq"
311+
}
312+
dies-ok { ().SetHash.pick(NaN) }, '().SetHash.pick(NaN) should die';
313+
}
314+
299315
# L<S32::Containers/SetHash/grab>
300316

301317
{

0 commit comments

Comments
 (0)