mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_objectspace.rb: missing tests from rubyspec
* test/ruby/test_objectspace.rb (test_each_object): incorporated from rubyspec. * test/ruby/test_objectspace.rb (test_each_object_enumerator): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
94da8b1737
commit
0bd9072758
1 changed files with 24 additions and 0 deletions
|
@ -85,6 +85,30 @@ End
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_each_object
|
def test_each_object
|
||||||
|
klass = Class.new
|
||||||
|
new_obj = klass.new
|
||||||
|
|
||||||
|
found = []
|
||||||
|
count = ObjectSpace.each_object(klass) do |obj|
|
||||||
|
found << obj
|
||||||
|
end
|
||||||
|
assert_equal(1, count)
|
||||||
|
assert_equal(1, found.size)
|
||||||
|
assert_same(new_obj, found[0])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_each_object_enumerator
|
||||||
|
klass = Class.new
|
||||||
|
new_obj = klass.new
|
||||||
|
|
||||||
|
found = []
|
||||||
|
counter = ObjectSpace.each_object(klass)
|
||||||
|
assert_equal(1, counter.each {|obj| found << obj})
|
||||||
|
assert_equal(1, found.size)
|
||||||
|
assert_same(new_obj, found[0])
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_each_object_no_gabage
|
||||||
assert_separately([], <<-End)
|
assert_separately([], <<-End)
|
||||||
GC.disable
|
GC.disable
|
||||||
eval('begin; 1.times{}; rescue; ensure; end')
|
eval('begin; 1.times{}; rescue; ensure; end')
|
||||||
|
|
Loading…
Add table
Reference in a new issue