aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_gc.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-10 02:47:05 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-10 02:47:05 +0000
commited729d398699aadb60ac79e19c276d4854083530 (patch)
tree1acdc301e716d1cc6a7d86bb036defbc5a4ff4bd /test/ruby/test_gc.rb
parent6b398398b90aa5adc9f18fd206b9f6f31af8a653 (diff)
downloadruby-ed729d398699aadb60ac79e19c276d4854083530.tar.gz
* gc.c (gc_stat_internal): rename `heap_used' to `heap_allocated_pages'.
ref: [Feature #9924] * test/ruby/test_gc.rb: add constraints test for gc stat information. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_gc.rb')
-rw-r--r--test/ruby/test_gc.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb
index e9993ce26c..b6b8b5d7d8 100644
--- a/test/ruby/test_gc.rb
+++ b/test/ruby/test_gc.rb
@@ -111,6 +111,19 @@ class TestGc < Test::Unit::TestCase
assert_raise(ArgumentError){ GC.stat(:invalid) }
end
+ def test_stat_constraints
+ stat = GC.stat
+ assert_equal stat[:total_allocated_pages], stat[:heap_allocated_pages] + stat[:total_freed_pages]
+ assert_operator stat[:heap_sorted_length], :>=, stat[:heap_allocated_pages] + stat[:heap_allocatable_pages]
+ assert_equal stat[:heap_available_slots], stat[:heap_live_slots] + stat[:heap_free_slots] + stat[:heap_final_slots]
+ assert_equal stat[:heap_live_slots], stat[:total_allocated_objects] - stat[:total_freed_objects] - stat[:heap_final_slots]
+
+ if use_rgengc?
+ assert_equal stat[:count], stat[:major_gc_count] + stat[:minor_gc_count]
+ assert_equal stat[:heap_allocated_pages], stat[:heap_eden_pages] + stat[:heap_tomb_pages]
+ end
+ end
+
def test_latest_gc_info
GC.start
count = GC.stat(:heap_free_slots) + GC.stat(:heap_allocatable_pages) * GC::INTERNAL_CONSTANTS[:HEAP_OBJ_LIMIT]