diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-25 03:18:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-25 03:18:13 +0000 |
commit | 0bd9072758f5c65edee17244e428e81e227f3af0 (patch) | |
tree | c51e077c5728485ed5d82212715e80c95a3bf273 /test | |
parent | 94da8b17374a71b451e9b7f3b6e97ab058bdbc81 (diff) | |
download | ruby-0bd9072758f5c65edee17244e428e81e227f3af0.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_objectspace.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_objectspace.rb b/test/ruby/test_objectspace.rb index a57c7ea1d1..cb17d03417 100644 --- a/test/ruby/test_objectspace.rb +++ b/test/ruby/test_objectspace.rb @@ -85,6 +85,30 @@ End end 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) GC.disable eval('begin; 1.times{}; rescue; ensure; end') |