From: Austin Ziegler Date: 2003-12-11T12:34:23+09:00 Subject: Re: Ideas for replacing $0==__FILE__ On Thu, 11 Dec 2003 06:21:37 +0900, Eric Hodel wrote: > Hal Fulton (hal9000@hypermetrics.com) wrote: >>> We also discussed on IRC having a "-t" flag to the ruby interpreter >>> that would run a TEST block (like BEGIN or END or at_exit), but >>> __TEST__ seems even better than that. >> Are we talking about the same thing? In my scheme, if foo.rb had a >> __TEST___ section, it would be run simply by ruby foo.rb (and not run >> if foo.rb was require'd). > This is different than your use. >> How does that relate to the -t idea (which I don' quite get)? > If you add -t to the ruby interpreter (ruby -t foo.rb) then __TEST__ get > run when ruby exits. ($TEST would also be set like -d sets $DEBUG). Hm. I'm not sure I like that. Why not: TEST { ... } The block is only run with ruby -t ...; otherwise it works just like BEGIN {} and END {} blocks. -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.12.10 * 22.33.01