digitalmars.D - AssertError
- Valery (8/8) Dec 30 2006 When I want to unittest the incorrect behaviour of a component, I
- Jarrett Billingsley (6/14) Dec 30 2006 It is in Phobos, it's just (very strangely) undocumented. Use "import
- BCS (2/13) Dec 30 2006 incluse std.asserterror;
- Lionello Lunesu (6/17) Jan 04 2007 I think there's a reason it's not documented.. There's something very
- Don Clugston (4/21) Jan 05 2007 You sometimes want to do it in a unit test -- eg, test that a function
When I want to unittest the incorrect behaviour of a component, I
often write something like
try {
// this code throws AssertError
} catch (Error e) { }
What I really want is to catch AssertError instead of Error, but
is is not in object nor elsewhere in phobos.
Is it possible to catch exactly AssertError ?
Dec 30 2006
"Valery" <valery freesurf.fr> wrote in message
news:en60i8$1aav$1 digitaldaemon.com...
When I want to unittest the incorrect behaviour of a component, I
often write something like
try {
// this code throws AssertError
} catch (Error e) { }
What I really want is to catch AssertError instead of Error, but
is is not in object nor elsewhere in phobos.
Is it possible to catch exactly AssertError ?
It is in Phobos, it's just (very strangely) undocumented. Use "import
std.asserterror" and then you can catch AssertErrors.
I'm not sure why this class is not defined in object.d, along with Exception
and Error. I mean, it's part of the language.
Dec 30 2006
Valery wrote:
When I want to unittest the incorrect behaviour of a component, I
often write something like
try {
// this code throws AssertError
} catch (Error e) { }
What I really want is to catch AssertError instead of Error, but
is is not in object nor elsewhere in phobos.
Is it possible to catch exactly AssertError ?
incluse std.asserterror;
Dec 30 2006
Valery wrote:
When I want to unittest the incorrect behaviour of a component, I
often write something like
try {
// this code throws AssertError
} catch (Error e) { }
What I really want is to catch AssertError instead of Error, but
is is not in object nor elsewhere in phobos.
Is it possible to catch exactly AssertError ?
I think there's a reason it's not documented.. There's something very
strange about wanting to catch an assert. There's no guarantee that the
assert gets compiled in. It would by like wanting to catch a
array-bounds error for, say, an invalid indexing like array[1000].
L.
Jan 04 2007
Lionello Lunesu wrote:Valery wrote:You sometimes want to do it in a unit test -- eg, test that a function correctly asserts when passed an invalid parameter. (And the same thing for array bounds errors).When I want to unittest the incorrect behaviour of a component, I often write something like try { // this code throws AssertError } catch (Error e) { } What I really want is to catch AssertError instead of Error, but is is not in object nor elsewhere in phobos. Is it possible to catch exactly AssertError ?I think there's a reason it's not documented.. There's something very strange about wanting to catch an assert. There's no guarantee that the assert gets compiled in. It would by like wanting to catch a array-bounds error for, say, an invalid indexing like array[1000].
Jan 05 2007









"Jarrett Billingsley" <kb3ctd2 yahoo.com> 