[前][次][番号順一覧][スレッド一覧]

ruby-changes:40667

From: nobu <ko1@a...>
Date: Wed, 25 Nov 2015 12:18:22 +0900 (JST)
Subject: [ruby-changes:40667] nobu:r52746 (trunk): test_objectspace.rb: missing tests from rubyspec

nobu	2015-11-25 12:18:13 +0900 (Wed, 25 Nov 2015)

  New Revision: 52746

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52746

  Log:
    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.

  Modified files:
    trunk/test/ruby/test_objectspace.rb
Index: test/ruby/test_objectspace.rb
===================================================================
--- test/ruby/test_objectspace.rb	(revision 52745)
+++ test/ruby/test_objectspace.rb	(revision 52746)
@@ -85,6 +85,30 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_objectspace.rb#L85
   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')

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]