From: Joost Diepenmaat Date: 2005-05-05T04:36:16+09:00 Subject: Re: Typo-checking instead of static typing On Thu, May 05, 2005 at 03:49:30AM +0900, Ben Giddings wrote: [ snip ] > def do_something(foo) > if foo > 500 > puts "Whoa, #{fo} is too many times! I can't do that!" > else > foo.times { |i| puts i } > end > end > > do_something(ARGV[0]) [ snip ] > Then there's the typo in the "puts" line. Until the person happens to try > an arg greater than 500, they will have no indication the code has a flaw. > > Now, would a unit test catch this? If the programmer was careful, maybe. > But maybe not. > > So, what advice would you guys give to a C programmer who wants a Ruby tool > to look over lines of code he may rarely execute? Use a code coverage tool to run over your unit tests, and fix your tests to go to 100% coverage. That's what I usually try to do in Perl anyway. Pointers to coverage tools for ruby anyone? Joost.