On Monday, September 9, 2024 6:40:07 PM MDT kookman via Digitalmars-d-learn wrote: > On Tuesday, 10 September 2024 at 00:27:43 UTC, Jonathan M Davis > > wrote: > > On Monday, September 9, 2024 5:46:18 PM MDT kookman via > > > > Digitalmars-d-learn wrote: > >> It seems like assertThrown works as expected for case 4, but > >> mysteriously not working for case 5 - despite the code under > >> test raising the same exception. Am I missing something stupid > >> here? > > > > At a glance, it looks like the part of case 5 which explicitly > > catches the Exception and the part that uses assertThrown > > should behave the same, but your example doesn't actually > > compile (you didn't include a definition for base32Alphabet), > > so it's not actually possible to reproduce your problem. > > > > - Jonathan M Davis > > Thanks Jonathan. Sorry I missed the excerpt for base32Alphabet - > included below: > > ``` > enum base32Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; > ```
When I run it locally, assertThrown passes as expected for test case 5, and the same happens on run.dlang.io, so nothing in my specific setup is making it pass when it normally wouldn't. So, unless you verified that your example failed (and since you forgot to include that enum, I suspect you didn't), I would guess that whatever your problem is went away when you reduced the code to provide the example for your question. I would note however, that the message for the AssertError that you provided did not come from assertThrown, since while assertThrown does take the file and line number from the caller, its message starts with "assertThrown failed:", whereas your error message was the generic message that you get from an assertion failure. So, whatever is going wrong in your code, assertThrown is not determining that your code didn't throw and then throwing an AssertError. It looks like an assertion on line #283 of whatever code you actually ran (which is clearly longer than the example you provided, since it's not that long) is failing. - Jonathan M Davis