On Sun, Oct 9, 2011 at 12:13 AM, Stefan Pöter
<stefan...@googlemail.com> wrote:
> expectThat(throwException(), throwsError());
There are a couple of things wrong here: the subject of the expectation should
be a function, not a call to that function, and `throwsError` takes a regular
expression describing the error. So it should look like this:
expectThat(throwException, throwsError(/foo.*bar/));
This works correctly if the error thrown is instantiated from one of the
built-in types (for example by saying `new TypeError('foo bar')`). Since
`throwsError` looks at the string form of the error but your error object
doesn't have a helpful `toString` method, it won't work for your custom error,
however.
I've filed two issues to make the output more helpful when the user makes
these mistakes:
http://code.google.com/p/google-js-test/issues/detail?id=16
http://code.google.com/p/google-js-test/issues/detail?id=17
Aaron
Great! This may be the first public user-written matcher. :-)
Aaron