gedaiu / fluent-asserts

DLang fluent assertions done right
http://fluentasserts.szabobogdan.com/
MIT License
43 stars 6 forks source link

Better way to check exception messages #8

Closed AntonMeep closed 7 years ago

AntonMeep commented 7 years ago

Currently this:

({
  throw new Exception("check me");
}).should.throwException!Exception.msg.should.contain("you");

Results in this:

... }).should.throwException!Exception.msg should contain `you` ...

I would like to see a better way to check exception messages, like this:

({
  throw new Exception("check me");
}).should.throwException!Exception.message.should.contain("you");

Which will give nice output:

... Message of Exception should contain `you`...
gedaiu commented 7 years ago

It's a good suggestion, but right now I don't know how I would implement it... I will think about it.

Anyway, an unit test would be helpful...

At the dconf they said that they will write the dmd frontend as a library, which will do this task easier to implement...

gedaiu commented 7 years ago

@ohdatboi I made some changes to the api and the exception errors look better now... what do you think?

AntonMeep commented 7 years ago

@gedaiu I like it! Thank you.