Skip to content

Commit

Permalink
Merge pull request #283 from ruby/fix-test-bundled-gems-3-4
Browse files Browse the repository at this point in the history
Workaround for test-bundled-gems at ruby/ruby repo
  • Loading branch information
hsbt authored Jan 18, 2024
2 parents 5843c89 + a77d775 commit 3816e76
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions test/bigdecimal/test_bigdecimal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,8 @@ def test_ctov
def test_split_under_gc_stress
bug3258 = '[ruby-dev:41213]'
expect = 10.upto(20).map{|i|[1, "1", 10, i+1].inspect}
assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, expect, [], bug3258)
paths = $LOAD_PATH.map{|path| "-I#{path}" }
assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, expect, [], bug3258)
GC.stress = true
10.upto(20) do |i|
p BigDecimal("1"+"0"*i).split
Expand All @@ -1777,7 +1778,8 @@ def test_split_under_gc_stress
end

def test_coerce_under_gc_stress
assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], [])
paths = $LOAD_PATH.map{|path| "-I#{path}" }
assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], [])
expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal"
b = BigDecimal("1")
GC.stress = true
Expand Down Expand Up @@ -1884,7 +1886,8 @@ def test_BigMath_exp_with_rational
end

def test_BigMath_exp_under_gc_stress
assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], [])
paths = $LOAD_PATH.map{|path| "-I#{path}" }
assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], [])
expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal"
10.times do
begin
Expand Down Expand Up @@ -2026,7 +2029,8 @@ def test_BigMath_log_with_reciprocal_of_42
end

def test_BigMath_log_under_gc_stress
assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], [])
paths = $LOAD_PATH.map{|path| "-I#{path}" }
assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], [])
expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal"
10.times do
begin
Expand Down Expand Up @@ -2073,7 +2077,8 @@ def test_to_d
end if RUBY_VERSION < '2.5' # mathn was removed from Ruby 2.5

def test_bug6406
assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], [])
paths = $LOAD_PATH.map{|path| "-I#{path}" }
assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], [])
Thread.current.keys.to_s
EOS
end
Expand Down Expand Up @@ -2283,21 +2288,14 @@ def test_bsearch_for_bigdecimal

def assert_no_memory_leak(code, *rest, **opt)
code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}"
super(["-rbigdecimal"],
paths = $LOAD_PATH.map{|path| "-I#{path}" }
super([*paths, "-rbigdecimal"],
"b = BigDecimal('10'); b.nil?; " \
"GC.add_stress_to_class(BigDecimal); "\
"#{code}", code, *rest, rss: true, limit: 1.1, **opt)
end

if EnvUtil.gc_stress_to_class?
def test_no_memory_leak_allocate
assert_no_memory_leak("BigDecimal.allocate")
end

def test_no_memory_leak_initialize
assert_no_memory_leak("BigDecimal()")
end

def test_no_memory_leak_BigDecimal
assert_no_memory_leak("BigDecimal('10')")
assert_no_memory_leak("BigDecimal(b)")
Expand Down

0 comments on commit 3816e76

Please sign in to comment.