diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-04 00:30:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-04 00:30:45 +0000 |
commit | 2c1aa7882045145807120746f600037ff37d164b (patch) | |
tree | 3f22b683e00cac120642ebcbbe106ee0873033c9 | |
parent | e758e9dab8d019f7723d6b32fc5d97123a5e43c3 (diff) | |
download | ruby-2c1aa7882045145807120746f600037ff37d164b.tar.gz |
adjust indent [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/objspace/test_objspace.rb | 119 |
1 files changed, 62 insertions, 57 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index c05c8c9992..7f8f247d9c 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -100,29 +100,30 @@ class TestObjSpace < Test::Unit::TestCase end def test_reachable_objects_from - assert_separately %w[--disable-gem -robjspace], __FILE__, __LINE__, <<-'eom' - assert_equal(nil, ObjectSpace.reachable_objects_from(nil)) - assert_equal([Array, 'a', 'b', 'c'], ObjectSpace.reachable_objects_from(['a', 'b', 'c'])) - - assert_equal([Array, 'a', 'a', 'a'], ObjectSpace.reachable_objects_from(['a', 'a', 'a'])) - assert_equal([Array, 'a', 'a'], ObjectSpace.reachable_objects_from(['a', v = 'a', v])) - assert_equal([Array, 'a'], ObjectSpace.reachable_objects_from([v = 'a', v, v])) - - long_ary = Array.new(1_000){''} - max = 0 - - ObjectSpace.each_object{|o| - refs = ObjectSpace.reachable_objects_from(o) - max = [refs.size, max].max - - unless refs.nil? - refs.each_with_index {|ro, i| - assert_not_nil(ro, "#{i}: this referenced object is internal object") - } - end - } - assert_operator(max, :>=, long_ary.size+1, "1000 elems + Array class") - eom + assert_separately %w[--disable-gem -robjspace], "#{<<-"begin;"}\n#{<<-'end;'}" + begin; + assert_equal(nil, ObjectSpace.reachable_objects_from(nil)) + assert_equal([Array, 'a', 'b', 'c'], ObjectSpace.reachable_objects_from(['a', 'b', 'c'])) + + assert_equal([Array, 'a', 'a', 'a'], ObjectSpace.reachable_objects_from(['a', 'a', 'a'])) + assert_equal([Array, 'a', 'a'], ObjectSpace.reachable_objects_from(['a', v = 'a', v])) + assert_equal([Array, 'a'], ObjectSpace.reachable_objects_from([v = 'a', v, v])) + + long_ary = Array.new(1_000){''} + max = 0 + + ObjectSpace.each_object{|o| + refs = ObjectSpace.reachable_objects_from(o) + max = [refs.size, max].max + + unless refs.nil? + refs.each_with_index {|ro, i| + assert_not_nil(ro, "#{i}: this referenced object is internal object") + } + end + } + assert_operator(max, :>=, long_ary.size+1, "1000 elems + Array class") + end; end def test_reachable_objects_from_root @@ -138,15 +139,16 @@ class TestObjSpace < Test::Unit::TestCase end def test_reachable_objects_size - assert_separately %w[--disable-gem -robjspace], __FILE__, __LINE__, <<-'eom' - ObjectSpace.each_object{|o| - ObjectSpace.reachable_objects_from(o).each{|reached_obj| - size = ObjectSpace.memsize_of(reached_obj) - assert_kind_of(Integer, size) - assert_operator(size, :>=, 0) + assert_separately %w[--disable-gem -robjspace], "#{<<~"begin;"}\n#{<<~'end;'}" + begin; + ObjectSpace.each_object{|o| + ObjectSpace.reachable_objects_from(o).each{|reached_obj| + size = ObjectSpace.memsize_of(reached_obj) + assert_kind_of(Integer, size) + assert_operator(size, :>=, 0) + } } - } - eom + end; end def test_trace_object_allocations @@ -276,44 +278,47 @@ class TestObjSpace < Test::Unit::TestCase end def test_dump_all_full - assert_in_out_err(%w[-robjspace], <<-'end;') do |output, error| - def dump_my_heap_please - ObjectSpace.dump_all(output: :stdout, full: true) - end + assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error| + begin; + def dump_my_heap_please + ObjectSpace.dump_all(output: :stdout, full: true) + end - dump_my_heap_please - end; - heap = output.find_all { |l| JSON.parse(l)['type'] == "NONE" } - assert_operator heap.length, :>, 0 + dump_my_heap_please + end; + heap = output.find_all { |l| JSON.parse(l)['type'] == "NONE" } + assert_operator heap.length, :>, 0 end end def test_dump_all entry = /"bytesize":11, "value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":/ - assert_in_out_err(%w[-robjspace], <<-'end;') do |output, error| - def dump_my_heap_please - ObjectSpace.trace_object_allocations_start - GC.start - str = "TEST STRING".force_encoding("UTF-8") - ObjectSpace.dump_all(output: :stdout) - end + assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}#{<<-'end;'}") do |output, error| + begin; + def dump_my_heap_please + ObjectSpace.trace_object_allocations_start + GC.start + str = "TEST STRING".force_encoding("UTF-8") + ObjectSpace.dump_all(output: :stdout) + end - dump_my_heap_please - end; + dump_my_heap_please + end; assert_match(entry, output.grep(/TEST STRING/).join("\n")) end - assert_in_out_err(%w[-robjspace], <<-'end;') do |(output), (error)| - def dump_my_heap_please - ObjectSpace.trace_object_allocations_start - GC.start - str = "TEST STRING".force_encoding("UTF-8") - ObjectSpace.dump_all().path - end + assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}#{<<-'end;'}") do |(output), (error)| + begin; + def dump_my_heap_please + ObjectSpace.trace_object_allocations_start + GC.start + str = "TEST STRING".force_encoding("UTF-8") + ObjectSpace.dump_all().path + end - puts dump_my_heap_please - end; + puts dump_my_heap_please + end; skip if /is not supported/ =~ error skip error unless output assert_match(entry, File.readlines(output).grep(/TEST STRING/).join("\n")) |