[macruby-changes] [1819] MacRuby/branches/experimental/spec/frozen/core/objectspace/ each_object_spec.rb

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 8 23:03:50 PDT 2009


Revision: 1819
          http://trac.macosforge.org/projects/ruby/changeset/1819
Author:   lsansonetti at apple.com
Date:     2009-06-08 23:03:50 -0700 (Mon, 08 Jun 2009)
Log Message:
-----------
improved a little bit the ObjectSpace#each_object spec

Modified Paths:
--------------
    MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb

Modified: MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb	2009-06-09 05:49:14 UTC (rev 1818)
+++ MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb	2009-06-09 06:03:50 UTC (rev 1819)
@@ -5,11 +5,27 @@
     class ObjectSpaceSpecEachObject; end
     new_obj = ObjectSpaceSpecEachObject.new
 
-    count = ObjectSpace.each_object(ObjectSpaceSpecEachObject) {}
+    yields = 0
+    count = ObjectSpace.each_object(ObjectSpaceSpecEachObject) do |obj|
+      obj.should == new_obj
+      yields += 1
+    end
     count.should == 1
+    yields.should == 1
     # this is needed to prevent the new_obj from being GC'd too early
     new_obj.should_not == nil
   end
+
+  it "calls the block once for each class, module in the Ruby process" do
+    [Class, Module].each do |k|
+      yields = 0
+      count = ObjectSpace.each_object(k) do |obj|
+        obj.kind_of?(Class).should == true
+        yields += 1
+      end
+      count.should == yields
+    end
+  end
   
   ruby_version_is '1.8.7' do
     it "returns an enumerator if not given a block" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090608/668a7571/attachment.html>


More information about the macruby-changes mailing list