Native Assertion module?

Dean Landolt dean at deanlandolt.com
Tue Feb 14 10:59:23 PST 2012


On Tue, Feb 14, 2012 at 1:50 PM, John J Barton
<johnjbarton at johnjbarton.com>wrote:

> On Tue, Feb 14, 2012 at 10:45 AM, Rick Waldron <waldron.rick at gmail.com>
> wrote:
> >
> >
> > On Tue, Feb 14, 2012 at 1:51 AM, David Herman <dherman at mozilla.com>
> wrote:
> >>
> >> On Feb 13, 2012, at 4:03 PM, Rick Waldron wrote:
> >>
> >> > I speak for myself and my colleagues when I say that we've had our
> fill
> >> > of including scripts _just_ for the sake of having a common testing
> >> > interface.
> >>
> >> A reasonable point. OTOH, I wouldn't want to over-engineer. And the
> larger
> >> the API, the harder it will be to standardize. I'm thinking maybe just a
> >> couple bare-bones primitives:
> >>
> >> 1. AssertionError <: Error
> >> 2. assert(x === 12); // throws an AssertionError with a default error
> >> message
> >> 3. assert(x === 12, "twelve, supposedly") // throws an AssertionError
> with
> >> the given error message
> >
> >
> > Bingo :)
>

+1

I assume nothing stops us from subtyping AssertionError either, right?


>  Is this significantly better than console.assert()?
>

Dave's assert throws an AssertionError (a new global, presumably?). But
more importantly, it *actually throws*, which is an important departure
from console.assert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120214/89796ea6/attachment.html>


More information about the es-discuss mailing list