mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
adjust indent [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e758e9dab8
commit
2c1aa78820
1 changed files with 58 additions and 53 deletions
|
@ -100,29 +100,30 @@ class TestObjSpace < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reachable_objects_from
|
def test_reachable_objects_from
|
||||||
assert_separately %w[--disable-gem -robjspace], __FILE__, __LINE__, <<-'eom'
|
assert_separately %w[--disable-gem -robjspace], "#{<<-"begin;"}\n#{<<-'end;'}"
|
||||||
assert_equal(nil, ObjectSpace.reachable_objects_from(nil))
|
begin;
|
||||||
assert_equal([Array, 'a', 'b', 'c'], ObjectSpace.reachable_objects_from(['a', 'b', 'c']))
|
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', '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', 'a'], ObjectSpace.reachable_objects_from(['a', v = 'a', v]))
|
||||||
assert_equal([Array, 'a'], ObjectSpace.reachable_objects_from([v = 'a', v, v]))
|
assert_equal([Array, 'a'], ObjectSpace.reachable_objects_from([v = 'a', v, v]))
|
||||||
|
|
||||||
long_ary = Array.new(1_000){''}
|
long_ary = Array.new(1_000){''}
|
||||||
max = 0
|
max = 0
|
||||||
|
|
||||||
ObjectSpace.each_object{|o|
|
ObjectSpace.each_object{|o|
|
||||||
refs = ObjectSpace.reachable_objects_from(o)
|
refs = ObjectSpace.reachable_objects_from(o)
|
||||||
max = [refs.size, max].max
|
max = [refs.size, max].max
|
||||||
|
|
||||||
unless refs.nil?
|
unless refs.nil?
|
||||||
refs.each_with_index {|ro, i|
|
refs.each_with_index {|ro, i|
|
||||||
assert_not_nil(ro, "#{i}: this referenced object is internal object")
|
assert_not_nil(ro, "#{i}: this referenced object is internal object")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
assert_operator(max, :>=, long_ary.size+1, "1000 elems + Array class")
|
assert_operator(max, :>=, long_ary.size+1, "1000 elems + Array class")
|
||||||
eom
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reachable_objects_from_root
|
def test_reachable_objects_from_root
|
||||||
|
@ -138,15 +139,16 @@ class TestObjSpace < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_reachable_objects_size
|
def test_reachable_objects_size
|
||||||
assert_separately %w[--disable-gem -robjspace], __FILE__, __LINE__, <<-'eom'
|
assert_separately %w[--disable-gem -robjspace], "#{<<~"begin;"}\n#{<<~'end;'}"
|
||||||
ObjectSpace.each_object{|o|
|
begin;
|
||||||
ObjectSpace.reachable_objects_from(o).each{|reached_obj|
|
ObjectSpace.each_object{|o|
|
||||||
size = ObjectSpace.memsize_of(reached_obj)
|
ObjectSpace.reachable_objects_from(o).each{|reached_obj|
|
||||||
assert_kind_of(Integer, size)
|
size = ObjectSpace.memsize_of(reached_obj)
|
||||||
assert_operator(size, :>=, 0)
|
assert_kind_of(Integer, size)
|
||||||
|
assert_operator(size, :>=, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
end;
|
||||||
eom
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_trace_object_allocations
|
def test_trace_object_allocations
|
||||||
|
@ -276,44 +278,47 @@ class TestObjSpace < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dump_all_full
|
def test_dump_all_full
|
||||||
assert_in_out_err(%w[-robjspace], <<-'end;') do |output, error|
|
assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error|
|
||||||
def dump_my_heap_please
|
begin;
|
||||||
ObjectSpace.dump_all(output: :stdout, full: true)
|
def dump_my_heap_please
|
||||||
end
|
ObjectSpace.dump_all(output: :stdout, full: true)
|
||||||
|
end
|
||||||
|
|
||||||
dump_my_heap_please
|
dump_my_heap_please
|
||||||
end;
|
end;
|
||||||
heap = output.find_all { |l| JSON.parse(l)['type'] == "NONE" }
|
heap = output.find_all { |l| JSON.parse(l)['type'] == "NONE" }
|
||||||
assert_operator heap.length, :>, 0
|
assert_operator heap.length, :>, 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dump_all
|
def test_dump_all
|
||||||
entry = /"bytesize":11, "value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":/
|
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|
|
assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}#{<<-'end;'}") do |output, error|
|
||||||
def dump_my_heap_please
|
begin;
|
||||||
ObjectSpace.trace_object_allocations_start
|
def dump_my_heap_please
|
||||||
GC.start
|
ObjectSpace.trace_object_allocations_start
|
||||||
str = "TEST STRING".force_encoding("UTF-8")
|
GC.start
|
||||||
ObjectSpace.dump_all(output: :stdout)
|
str = "TEST STRING".force_encoding("UTF-8")
|
||||||
end
|
ObjectSpace.dump_all(output: :stdout)
|
||||||
|
end
|
||||||
|
|
||||||
dump_my_heap_please
|
dump_my_heap_please
|
||||||
end;
|
end;
|
||||||
assert_match(entry, output.grep(/TEST STRING/).join("\n"))
|
assert_match(entry, output.grep(/TEST STRING/).join("\n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_in_out_err(%w[-robjspace], <<-'end;') do |(output), (error)|
|
assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}#{<<-'end;'}") do |(output), (error)|
|
||||||
def dump_my_heap_please
|
begin;
|
||||||
ObjectSpace.trace_object_allocations_start
|
def dump_my_heap_please
|
||||||
GC.start
|
ObjectSpace.trace_object_allocations_start
|
||||||
str = "TEST STRING".force_encoding("UTF-8")
|
GC.start
|
||||||
ObjectSpace.dump_all().path
|
str = "TEST STRING".force_encoding("UTF-8")
|
||||||
end
|
ObjectSpace.dump_all().path
|
||||||
|
end
|
||||||
|
|
||||||
puts dump_my_heap_please
|
puts dump_my_heap_please
|
||||||
end;
|
end;
|
||||||
skip if /is not supported/ =~ error
|
skip if /is not supported/ =~ error
|
||||||
skip error unless output
|
skip error unless output
|
||||||
assert_match(entry, File.readlines(output).grep(/TEST STRING/).join("\n"))
|
assert_match(entry, File.readlines(output).grep(/TEST STRING/).join("\n"))
|
||||||
|
|
Loading…
Reference in a new issue