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

source_changes at macosforge.org source_changes at macosforge.org
Tue Jun 9 12:15:37 PDT 2009


Revision: 1830
          http://trac.macosforge.org/projects/ruby/changeset/1830
Author:   lsansonetti at apple.com
Date:     2009-06-09 12:15:29 -0700 (Tue, 09 Jun 2009)
Log Message:
-----------
rewrote a spec to not generate 5000 expectations

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 09:17:04 UTC (rev 1829)
+++ MacRuby/branches/experimental/spec/frozen/core/objectspace/each_object_spec.rb	2009-06-09 19:15:29 UTC (rev 1830)
@@ -17,15 +17,18 @@
     new_obj.should_not == nil
   end
 
-  # TODO: This really generates a whole lot of expectations (~5000 thousand).
-  # Can't we define our own class like above?
   it "calls the block once for each class, module in the Ruby process" do
-    [Class, Module].each do |k|
+    class ObjectSpaceSpecEachClass; end
+    module ObjectSpaceSpecEachModule; end
+
+    [ObjectSpaceSpecEachClass, ObjectSpaceSpecEachModule].each do |k|
       yields = 0
-      count = ObjectSpace.each_object(k) do |obj|
-        obj.kind_of?(Class).should == true
+      got_it = false
+      count = ObjectSpace.each_object(k.class) do |obj|
+        got_it = true if obj == k
         yields += 1
       end
+      got_it.should == true
       count.should == yields
     end
   end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090609/a7c2e211/attachment.html>


More information about the macruby-changes mailing list