Skip to content

Commit

Permalink
Add tests for empty Set(|Hash).pick handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed May 21, 2017
1 parent c4c10d5 commit 4dfee69
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 17 additions & 1 deletion S02-types/set.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 189;
plan 197;

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

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

# empty set handling of .pick
{
is-deeply set().pick, Nil, 'empty set.pick -> Nil';
for
1, '1',
*-1, '*-1',
*, '*',
Inf, 'Inf',
-1, '-1',
-Inf, '-Inf'
-> $p, $t {
is-deeply set().pick($p), ().Seq, "empty set.rpick($t) -> ().Seq"
}
dies-ok { set().pick(NaN) }, 'empty set.pick(NaN) should die';
}

# L<S32::Containers/Set/grab>

{
Expand Down
18 changes: 17 additions & 1 deletion S02-types/sethash.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 229;
plan 237;

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

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

# empty SetHash handling of .pick
{
is-deeply ().SetHash.pick, Nil, '().SetHash.pick -> Nil';
for
1, '1',
*-1, '*-1',
*, '*',
Inf, 'Inf',
-1, '-1',
-Inf, '-Inf'
-> $p, $t {
is-deeply ().SetHash.pick($p), ().Seq, "().SetHash.pick($t) -> ().Seq"
}
dies-ok { ().SetHash.pick(NaN) }, '().SetHash.pick(NaN) should die';
}

# L<S32::Containers/SetHash/grab>

{
Expand Down

0 comments on commit 4dfee69

Please sign in to comment.