On Friday, 16 February 2024 at 07:43:24 UTC, Ferhat Kurtulmuş wrote:
When I tried to catch exceptions in my unit test, I found that exceptions were not thrown or caught in the unit test blocks. So, I cannot use assertThrown at all. Is this a bug or expected behavior that I don't know?

Using LDC 1.36.0 on Windows.

https://github.com/aferust/evalex/blob/main/source/evalex.d#L694

Even a test code like this does not work:

```d
string division(int a, int b) {
   string result = "";

   try {
      if( b == 0 ) {
         throw new Exception("Cannot divide by zero!");
      } else {
         result = format("%s",a/b);
      }
   } catch (Exception e) {
      result = e.msg;
   }

   return result;
}

assertThrown({division(50, 0);});
```
  • Are exceptions c... Ferhat Kurtulmuş via Digitalmars-d-learn
    • Re: Are exc... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Are... Ferhat Kurtulmuş via Digitalmars-d-learn
    • Re: Are exc... Ferhat Kurtulmuş via Digitalmars-d-learn
      • Re: Are... Jonathan M Davis via Digitalmars-d-learn
      • Re: Are... Ferhat Kurtulmuş via Digitalmars-d-learn

Reply via email to