Hello,

While getting to know QUnit, I noticed that there is currently no way
to test for the occurrence of exceptions.
Looking at the QUnit source, it appears this might be an easy thing to
add:
    http://gist.github.com/76340

That way one could write tests like so:
    var expression, expected;
    var L = ["foo", "bar", "baz"];

    // should pass
    expression = function() { return foo.bar; };
    expected = "TypeError";
    throwsEx(expression, expected, "invalid property access raises
TypeError exception");

    // should fail
    expression = function() { var foo = {}; return foo.bar; };
    expected = "NoneError";
    throwsEx(expression, expected, "property access raises NoneError
exception");

Note that I'm using closures to wrap around the expression which is
actually being tested.

Does this seem sensible?
I'd be happy to submit a patch on request.


-- Fred

Reply via email to