I have a condition that uses warn
something like (its just an illustration)
sub abc {
...
if $iterations > 150 {
$iterations = 150;
warn 'excess recursion, clamping at 150';
}
....
In my test suite I tried
....
throws-like { abc('excess') }, Exception, 'got the exception', message
=> / excess recursion /;
....
However, this fails to pick up the exception and I get something like:
excess recursion, clamping at 150
not ok 1 - code dies
# Failed test 'code dies'
# at t/basic.t line 56
ok 2 - # SKIP Code did not die, can not check exception
ok 3 - # SKIP Code did not die, can not check exception
# Looks like you failed 1 test of 3
lives-ok { abc('excess') }, 'got the exception';
passes the test, but does not verify that the correct warning message
was passed, and in any case, this test would pass even if the exception
condition wasn't fulfilled.
Have I missed something?
I could use the module Test:::Output, to test std-err, but this seems
inappropriate for what is a core sub like warn.