From: Austin Ziegler Date: 2003-12-11T14:20:01+09:00 Subject: Re: Ideas for replacing $0==__FILE__ On Thu, 11 Dec 2003 12:38:37 +0900, Jamis Buck wrote: > Austin Ziegler wrote: >>> 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. > I like that--in fact, I'd probably use it. What happens if there are > multiple TEST{} blocks (especially in required files)? Do they all get > executed? I would suggest yes. Perhaps -t and -tr (e.g., -t only runs the last; -tr runs all). What was brought up on #ruby-lang is whether the TEST {} blocks would be exclusive, overriding normal behaviour. This may be desirable. -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.12.11 * 00.17.28