"NAKAMURA, Hiroshi" <nahi / keynauts.com> writes:

> >   ruby -r SelfTest  mylibrary.rb
> 
> This looks good.  Can I show another soultion?
> 
>   if $DEBUG
>     # code to perform test
>   end

Absolutely. (We should say that $DEBUG is set to true by the -d
command line option).

> But I will test my library with RubyUnit in the future.

Andy and I are really enjoying using it.


Let me float an idea...

Say you want to include RubyUnit test code in your library's
source. Rather than using 'if $DEBUG' or similar, is there any
advantage to doing something like:

  =begin RubyUnit

     <tests>

  =end RubyUnit


and then having something that extracted and ran these

  ruby ru myfile.rb


I don't know if this is good or bad -- I can see both advantages and
disadvantages. What do people think?



Dave