diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index deb2fa9a57..975983c029 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1093,28 +1093,29 @@ class TestBigDecimal < Test::Unit::TestCase def test_split_under_gc_stress bug3258 = '[ruby-dev:41213]' - stress, GC.stress = GC.stress, true + expect = 10.upto(20).map{|i|[1, "1", 10, i+1].inspect} + assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, expect, [], bug3258) + GC.stress = true 10.upto(20) do |i| - b = BigDecimal.new("1"+"0"*i) - assert_equal([1, "1", 10, i+1], b.split, bug3258) + p BigDecimal.new("1"+"0"*i).split end - ensure - GC.stress = stress + EOS end def test_coerce_under_gc_stress - expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" - under_gc_stress do + assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" b = BigDecimal.new("1") + GC.stress = true 10.times do begin b.coerce(:too_long_to_embed_as_string) rescue => e - assert_instance_of TypeError, e - assert_equal expect, e.message + raise unless e.is_a?(TypeError) + raise "'\#{expect}' is expected, but '\#{e.message}'" unless e.message == expect end end - end + EOS end def test_INFINITY @@ -1178,17 +1179,17 @@ class TestBigDecimal < Test::Unit::TestCase end def test_BigMath_exp_under_gc_stress - expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" - under_gc_stress do + assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin BigMath.exp(:too_long_to_embed_as_string, 6) rescue => e - assert_instance_of ArgumentError, e - assert_equal expect, e.message + raise unless e.is_a?(ArgumentError) + raise "'\#{expect}' is expected, but '\#{e.message}'" unless e.message == expect end end - end + EOS end def test_BigMath_log_with_nil @@ -1277,17 +1278,17 @@ class TestBigDecimal < Test::Unit::TestCase end def test_BigMath_log_under_gc_stress - expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" - under_gc_stress do + assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin BigMath.log(:too_long_to_embed_as_string, 6) rescue => e - assert_instance_of ArgumentError, e - assert_equal expect, e.message + raise unless e.is_a?(ArgumentError) + raise "'\#{expect}' is expected, but '\#{e.message}'" unless e.message == expect end end - end + EOS end def test_dup