Skip to content

Commit bbf5ce7

Browse files
authored
Remove gc_compaction test (#401)
BigDecimal was GC compaction unsafe because of its structure (T_DATA contains back reference to VALUE). Now that the structure is changed and back reference is removed, we don't need this kind of test just like other c-extension libraries.
1 parent 48e32bc commit bbf5ce7

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

test/bigdecimal/test_bigdecimal.rb

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,53 +2565,6 @@ def test_bsearch_for_bigdecimal
25652565
}
25662566
end
25672567

2568-
def test_gc_compaction_safe
2569-
omit if RUBY_VERSION < "3.2" || RUBY_ENGINE == "truffleruby"
2570-
2571-
assert_separately(["-rbigdecimal"], "#{<<~"begin;"}\n#{<<~'end;'}")
2572-
begin;
2573-
x = 1.5
2574-
y = 0.5
2575-
nan = BigDecimal("NaN")
2576-
inf = BigDecimal("Infinity")
2577-
bx = BigDecimal(x.to_s)
2578-
by = BigDecimal(y.to_s)
2579-
GC.verify_compaction_references(expand_heap: true, toward: :empty)
2580-
2581-
assert_in_delta(x + y, bx + by)
2582-
assert_in_delta(x + y, bx.add(by, 10))
2583-
assert_in_delta(x - y, bx - by)
2584-
assert_in_delta(x - y, bx.sub(by, 10))
2585-
assert_in_delta(x * y, bx * by)
2586-
assert_in_delta(x * y, bx.mult(by, 10))
2587-
assert_in_delta(x / y, bx / by)
2588-
assert_in_delta(x / y, bx.div(by, 10))
2589-
assert_in_delta((x / y).floor, bx.div(by))
2590-
assert_in_delta(x % y, bx % by)
2591-
assert_in_delta(Math.sqrt(x), bx.sqrt(10))
2592-
assert_equal(x.div(y), bx.div(by))
2593-
assert_equal(x.remainder(y), bx.remainder(by))
2594-
assert_equal(x.divmod(y), bx.divmod(by))
2595-
assert_equal([0, x], bx.divmod(inf))
2596-
assert_in_delta(x, bx.remainder(inf))
2597-
assert((nan + nan).nan?)
2598-
assert((nan - nan).nan?)
2599-
assert((nan * nan).nan?)
2600-
assert((nan / nan).nan?)
2601-
assert((nan % nan).nan?)
2602-
assert((inf + inf).infinite?)
2603-
assert((inf - inf).nan?)
2604-
assert((inf * inf).infinite?)
2605-
assert((inf / inf).nan?)
2606-
assert((inf % inf).nan?)
2607-
assert_in_delta(Math.exp(x), BigMath.exp(bx, 10))
2608-
assert_in_delta(x**y, bx**by)
2609-
assert_in_delta(x**y, bx.power(by, 10))
2610-
assert_in_delta(Math.exp(x), BigMath.exp(bx, 10))
2611-
assert_in_delta(Math.log(x), BigMath.log(bx, 10))
2612-
end;
2613-
end
2614-
26152568
def assert_no_memory_leak(code, *rest, **opt)
26162569
code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}"
26172570
paths = $LOAD_PATH.map{|path| "-I#{path}" }

0 commit comments

Comments
 (0)