Gavin Sinclair
11/13/2004 2:00:00 AM
On Saturday, November 13, 2004, 12:46:23 PM, Gavin wrote:
> On Saturday, November 13, 2004, 7:28:26 AM, Florian wrote:
>> itsme213 wrote:
>>> I could not find a standard "assert" in Ruby. Is there one?
>> There's one in the dev-utils package. It will automatically set a
>> breakpoint if the application is run in debug mode and therefore give
>> you an irb shell where you can find out why your assert failed.
> It's not there at the moment (I don't think). And the OP probably
> wants an exception raised, not an IRB session :)
While writing that message, I realised why a breakpoint-inducing
assert would be handy. Let's call it assert_bp, since the bare name
'assert' so strongly implies "raise an error if expression is false".
Code:
x = 5
y = 6
assert_bp "x + y = 100"
Console:
Assert failed: x + y = 100 (foo/bar.rb:51)
irb> _
Now, can anyone suggest a better name than 'assert_bp'?
Gavin