Skip to content

Commit

Permalink
Add .Mix(|Hash) tests for illegal values
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jun 7, 2017
1 parent 7a88a38 commit f83f077
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion S02-types/mix.t
Expand Up @@ -3,7 +3,7 @@ use lib <t/spec/packages>;
use Test::Util;
use Test;

plan 203;
plan 213;

sub showkv($x) {
$x.keys.sort.map({ $^k ~ ':' ~ $x{$k} }).join(' ')
Expand Down Expand Up @@ -496,6 +496,13 @@ subtest '.hash does not cause keys to be stringified' => {
{
throws-like { ^Inf .Mix }, X::Cannot::Lazy, :what<Mix>;
throws-like { Mix.new-from-pairs(^Inf) }, X::Cannot::Lazy, :what<Mix>;

for a=>"a", a=>Inf, a=>-Inf, a=>NaN, a=>3i -> $pair {
dies-ok { $pair.Mix },
"($pair.perl()).Mix died";
dies-ok { Mix.new-from-pairs($pair) },
"Mix.new-from-pairs( ($pair.perl()) ) died";
}
}

# vim: ft=perl6
9 changes: 8 additions & 1 deletion S02-types/mixhash.t
Expand Up @@ -3,7 +3,7 @@ use lib <t/spec/packages>;
use Test::Util;
use Test;

plan 247;
plan 257;

# L<S02/Mutable types/QuantHash of UInt>

Expand Down Expand Up @@ -585,6 +585,13 @@ subtest 'MixHash autovivification of non-existent keys' => {
{
throws-like { ^Inf .MixHash }, X::Cannot::Lazy, :what<MixHash>;
throws-like { MixHash.new-from-pairs(^Inf) }, X::Cannot::Lazy, :what<MixHash>;

for a=>"a", a=>Inf, a=>-Inf, a=>NaN, a=>3i -> $pair {
dies-ok { $pair.MixHash },
"($pair.perl()).MixHash died";
dies-ok { MixHash.new-from-pairs($pair) },
"MixHash.new-from-pairs( ($pair.perl()) ) died";
}
}

# vim: ft=perl6

0 comments on commit f83f077

Please sign in to comment.