reasonml / reason-native

Testing, printing, coloring, and other tools to effectively write native Reason code.
https://reason-native.com/
MIT License
460 stars 43 forks source link

[Rely] Add optional comparator for .toThrowException matcher #190

Open bandersongit opened 5 years ago

bandersongit commented 5 years ago

Right now expect.fn.toThrowException matches exceptions based on ==. I could easily imagine wanting to ignore a message and just match on the constructor itself. E.g. I just want to make sure an Invalid_argument is thrown, I don't care what the message is for the purposes of my test.

I could see this also being applicable for floats or really for any string arguments to an exception constructor.

Adding the ability to specify a custom ~equals function that defaults to == would address all these concerns and be consistent with what we do for floats/arrays/lists/expectEqual etc.

This would be a great first issue for anyone to pick up. The relevant code can be found int he FnMatchers.re file

bandersongit commented 5 years ago

The mock matcher toThrowException should be similarly updated and can be found in MockMatchers.re