[macruby-changes] [4348] MacRuby/trunk/spec/macruby

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 13 15:37:00 PDT 2010


Revision: 4348
          http://trac.macosforge.org/projects/ruby/changeset/4348
Author:   ernest.prabhakar at gmail.com
Date:     2010-07-13 15:36:57 -0700 (Tue, 13 Jul 2010)
Log Message:
-----------
Fixed GCD source specs by using semaphore vs. queue-based wait

Modified Paths:
--------------
    MacRuby/trunk/spec/macruby/core/gcd/source_spec.rb
    MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt

Modified: MacRuby/trunk/spec/macruby/core/gcd/source_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/gcd/source_spec.rb	2010-07-13 22:05:34 UTC (rev 4347)
+++ MacRuby/trunk/spec/macruby/core/gcd/source_spec.rb	2010-07-13 22:36:57 UTC (rev 4348)
@@ -52,6 +52,7 @@
     describe "of type" do
       before :each do
         @q = Dispatch::Queue.new('org.macruby.gcd_spec.sources')
+        @sm = Dispatch::Semaphore.new(0)
       end
 
       after :each do
@@ -75,9 +76,9 @@
 
         it "fires event handler on merge" do
           @i = 0
-          src = Dispatch::Source.new(@type, 0, 0, @q) {|s|  @i = 42}
+          src = Dispatch::Source.new(@type, 0, 0, @q) {|s|  @i = 42; @sm.signal}
           src << 42
-          @q.sync { }
+          @sm.wait
           @i.should == 42
         end        
 
@@ -85,9 +86,10 @@
           @flag = false
           src = Dispatch::Source.new(@type, 0, 0, @q) do |source|
             @flag = (source.is_a? Dispatch::Source)
+            @sm.signal
           end
           src << 42
-          @q.sync { }
+          @sm.wait
           @flag.should == true
         end        
 
@@ -95,9 +97,10 @@
           @i = 0
           src = Dispatch::Source.new(@type, 0, 0, @q) do |source|
             @i = source.data
+            @sm.signal
           end
           src << 42
-          @q.sync { }
+          @sm.wait
           @i.should == 42
         end        
 
@@ -105,12 +108,13 @@
           @i = 0
           src = Dispatch::Source.new(@type, 0, 0, @q) do |source|
             @i = source.data
+            @sm.signal
           end
           src.suspend!
           src << 17
           src << 25
           src.resume!
-          @q.sync { }
+          @sm.wait
           @i.should == 42
         end        
       end
@@ -128,9 +132,9 @@
 
         it "fires event handler on merge" do
           @i = 0
-          src = Dispatch::Source.new(@type, 0, 0, @q) {|s|  @i = 42}
+          src = Dispatch::Source.new(@type, 0, 0, @q) {|s|  @i = 42; @sm.signal}
           src << 42
-          @q.sync { }
+          @sm.wait
           @i.should == 42
         end        
         
@@ -138,12 +142,13 @@
           @i = 0
           src = Dispatch::Source.new(@type, 0, 0, @q) do |source|
             @i = source.data
+            @sm.signal
           end
           src.suspend!
           src << 0b000_010
           src << 0b101_000
           src.resume!
-          @q.sync { }
+          @sm.wait
           @i.should == 42 #0b101_010
           src.cancel!
         end        
@@ -169,11 +174,12 @@
           src = Dispatch::Source.new(@type, $$, @mask, @q) do |s|
             @i = s.data
             @fired = true
+            @sm.signal
           end
           Signal.trap(@signal, "IGNORE")
           Process.kill(@signal, $$)
           Signal.trap(@signal, "DEFAULT")
-          @q.sync { }
+          @sm.wait
           #while (@fired == false) do; end
           @fired.should == true
           @i.should == @mask
@@ -199,12 +205,12 @@
           src = Dispatch::Source.new(@type, @signal, 0, @q) do |s|
             @i = s.data
             @fired = true
+            @sm.signal
           end
           Signal.trap(@signal, "IGNORE")
           Process.kill(@signal, $$)
           Signal.trap(@signal, "DEFAULT")
-          @q.sync { }
-          #while (@fired == false) do; end
+          @sm.wait
           @fired.should == true
           @i.should == 1
           src.cancel!
@@ -336,11 +342,11 @@
             @src = Dispatch::Source.new(@type, @file.to_i, @mask, @q) do |s|
                 @flag = s.data
                 @fired = true
+                @sm.signal
             end
             @file.write(@msg)
             @file.flush
-            @q.sync { }
-            #while (@fired == false) do; end
+            @sm.wait
             @fired.should == true
             @flag.should == @mask
           end    
@@ -348,7 +354,7 @@
           it "does not close file when cancelled given descriptor" do
             @src = Dispatch::Source.new(@type, @file.to_i, 0, @q) { }
             @src.cancel!
-            @q.sync { }
+            @sm.wait
             @file.closed?.should == false
           end
 

Modified: MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt	2010-07-13 22:05:34 UTC (rev 4347)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt	2010-07-13 22:36:57 UTC (rev 4348)
@@ -1,11 +1,2 @@
-fails:Dispatch::Source of type SIGNAL fires on signal with signal count data
-fails:Dispatch::Source of type DATA_ADD passes source to event handler
-fails:Dispatch::Source of type file: READ does close file when cancelled given IO
-fails:Dispatch::Source of type file: VNODE fires with data showing mask of vnode events
-fails:Dispatch::Source Timer fires every interval thereafter
-fails:Dispatch::Source of type file: VNODE does close file when cancelled given IO
-fails:Dispatch::Source of type file: WRITE does close file when cancelled given IO
-fails:Dispatch::Source of type PROC fires on process event with event mask data
-fails:Dispatch::Source of type DATA_ADD coalesces data for source in event handler
-fails:Dispatch::Source of type DATA_OR fires event handler on merge
-fails:Dispatch::Source of type DATA_OR coalesces data for source in event handler
+fails:Dispatch::Source of type file: VNODE does not close file when cancelled given descriptor
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100713/a102705e/attachment-0001.html>


More information about the macruby-changes mailing list