Skip to content

Commit

Permalink
[v6.d REVIEW] Test actual exceptions in Bag/BagHash throwage
Browse files Browse the repository at this point in the history
Orig: 7a88a38e2
  • Loading branch information
zoffixznet committed Sep 21, 2018
1 parent 8c8e8f5 commit f3b8601
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions S02-types/bag.t
Expand Up @@ -550,10 +550,12 @@ subtest '.hash does not cause keys to be stringified' => {
throws-like { Bag.new(^Inf) }, X::Cannot::Lazy, :what<Bag>;

for a=>"a", a=>Inf, a=>-Inf, a=>NaN, a=>3i -> $pair {
dies-ok { $pair.Bag },
"($pair.perl()).Bag died";
dies-ok { Bag.new-from-pairs($pair) },
"Bag.new-from-pairs( ($pair.perl()) ) died";
my \ex := $pair.value eq 'a'
?? X::Str::Numeric !! X::Numeric::CannotConvert;
throws-like { $pair.Bag }, ex,
"($pair.perl()).Bag throws";
throws-like { Bag.new-from-pairs($pair) }, ex,
"Bag.new-from-pairs( ($pair.perl()) ) throws";
}
}

Expand Down
10 changes: 6 additions & 4 deletions S02-types/baghash.t
Expand Up @@ -659,10 +659,12 @@ subtest 'BagHash autovivification of non-existent keys' => {
throws-like { BagHash.new(^Inf) }, X::Cannot::Lazy, :what<BagHash>;

for a=>"a", a=>Inf, a=>-Inf, a=>NaN, a=>3i -> $pair {
dies-ok { $pair.BagHash },
"($pair.perl()).BagHash died";
dies-ok { BagHash.new-from-pairs($pair) },
"BagHash.new-from-pairs( ($pair.perl()) ) died";
my \ex := $pair.value eq 'a'
?? X::Str::Numeric !! X::Numeric::CannotConvert;
throws-like { $pair.BagHash }, ex,
"($pair.perl()).BagHash throws";
throws-like { BagHash.new-from-pairs($pair) }, ex,
"BagHash.new-from-pairs( ($pair.perl()) ) throws";
}
}

Expand Down

0 comments on commit f3b8601

Please sign in to comment.