Brian Buckley wrote:

> In the code below the first test by itself passes. However, when I add a 
> second test called "test_bad_data", the first test fails. The method count 
> on BigDecimal apppears to change from 82 to 86.
> 
> I've noticed that if I give "test_bad_data" a different test name (but still 
> starting with "test_") all works as expected.
> 
> What's happening?

I'm not sure, since I can't reproduce the problem:

t.rb:
   require 'test/unit'
   require 'bigdecimal'

   $include_bad_data = ARGV[0]

   class TestBigDecimal < Test::Unit::TestCase
     def test_method_count
       assert_equal 83, BigDecimal.methods.size
     end

     if($include_bad_data)
       def test_bad_data
         assert_equal "", "0.0" #causes first test to fail
       end
     end
   end

Output:

   C:\TEMP>ruby -v t.rb
   ruby 1.8.2 (2005-04-21) [i386-mswin32]
   Loaded suite t
   Started
   .
   Finished in 0.0 seconds.

   1 tests, 1 assertions, 0 failures, 0 errors

   C:\TEMP>ruby -v t.rb -- a
   ruby 1.8.2 (2005-04-21) [i386-mswin32]
   Loaded suite t
   Started
   F.
   Finished in 0.0 seconds.

     1) Failure:
   test_bad_data(TestBigDecimal) [t.rb:14]:
   <""> expected but was
   <"0.0">.

   2 tests, 2 assertions, 1 failures, 0 errors


Seems normal to me... now I am running a stable snapshot, and had a 
different number of initial methods in BigDecimal... what version of 
Ruby are you seeing this behavior on?


--
Nathaniel

<:((><