From: Florian Gross Date: 2004-11-15T22:13:24+09:00 Subject: Re: assert Bjorn Nordbo wrote: > Gavin Sinclair writes: >>It's not unlikely at all, actually. Test cases are a clearly a good >>way to set up the conditions you need to expose a bug. That's when I >>tend to use breakpoints very often. > > I think there are are least two common scenarios described here: > > 1. You want an assertion as kind of a "can't happen" test. > 2. You want to set breakpoints to inspect the state. > > In my opinion, the first is the traditional "assert" while the second is > similiar to BREAK in Common Lisp. The former is useful in both test and > production code, while the latter only makes sense in test code. These > are different, and should have different names: > > - "assert" or similiar to die horriby (except maybe when $DEBUG is set) > - "breakpoint" or similiar to simply interrupt execution. assert() doesn't die horribly in test cases either and when you find something wrong it can make sense to let a developer examine state so that the problem can be fixed instead of dieing without a way of diagnosing problems. I renamed the assert() that spawns an irb shell to assume() mostly to avoid collisions with test/unit. Personally I don't think it makes much sense to spawn an irb shell in test cases where you already have the problems clearly isolated anyway -- but test cases will require() the main application and if the main application still uses breakpoint.rb there will be a collision between test/unit's assert() and breakpoint's assert(). I guess assume() would be okay -- if anybody dislikes it and would rather use breakpoint() manually then great, I'm not forcing anybody to use assume() instead of breakpoint(). I have just found it useful to have both in my own code. I just wonder if anybody would run into real problems because of breakpoint.rb providing assume().