[macruby-changes] [3251] MacRuby/trunk/spec/macruby
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jan 11 17:33:07 PST 2010
Revision: 3251
http://trac.macosforge.org/projects/ruby/changeset/3251
Author: ernest.prabhakar at gmail.com
Date: 2010-01-11 17:33:06 -0800 (Mon, 11 Jan 2010)
Log Message:
-----------
Added signal gauards so Dispatch::Source :PROC and :SIGNAL pass
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-01-12 01:33:04 UTC (rev 3250)
+++ MacRuby/trunk/spec/macruby/core/gcd/source_spec.rb 2010-01-12 01:33:06 UTC (rev 3251)
@@ -145,13 +145,12 @@
@i.should == 42 #0b101_010
end
end
-
+
describe :PROC do
before :each do
@type = Dispatch::Source::PROC
@mask = Dispatch::Source::PROC_SIGNAL
- @signal = Signal.list["USR2"]
- Signal.trap(@signal, "IGNORE")
+ @signal = Signal.list["USR1"]
end
it "returns an active instance of Dispatch::Source" do
@@ -160,27 +159,39 @@
src.suspended?.should == false
end
- it "fires event handler on process event" do
+ it "fires with event mask on process event" do
@i = 0
- src = Dispatch::Source.new(@type, $$, @mask, @q) { |s| @i += 42 }
- Process.kill(@signal, $$) # send myself a SIGUSR2
+ src = Dispatch::Source.new(@type, $$, @mask, @q) { |s| @i = s.data }
+ Signal.trap(@signal, "IGNORE")
+ Process.kill(@signal, $$)
+ Signal.trap(@signal, "DEFAULT")
@q.sync { }
- @i.should == 42
+ @i.should == @mask
+ src.cancel!
end
-
- #The second spec always fails; can't send the same signal twice?!?
- it "passes event mask as data" do
+ end
+
+ describe :SIGNAL do
+ before :each do
+ @type = Dispatch::Source::SIGNAL
+ @signal = Signal.list["USR2"]
+ end
+
+ it "returns an instance of Dispatch::Source" do
+ src = Dispatch::Source.new(@type, @signal, 0, @q) { }
+ src.should be_kind_of(Dispatch::Source)
+ end
+
+ it "fires with signal count on signal" do
@i = 0
- src = Dispatch::Source.new(@type, $$, @mask, @q) { |s| @i = s.data }
- Process.kill(@signal, $$) # send myself a SIGUSR2
+ src = Dispatch::Source.new(@type, @signal, 0, @q) { |s| @i = s.data }
+ Signal.trap(@signal, "IGNORE")
+ Process.kill(@signal, $$)
+ Signal.trap(@signal, "DEFAULT")
@q.sync { }
- @i.should == @mask
+ @i.should == 1
+ src.cancel!
end
-
- after :each do
- #Signal.trap(@signal, "DEFAULT")
- end
-
end
describe :READ do
Modified: MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt 2010-01-12 01:33:04 UTC (rev 3250)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt 2010-01-12 01:33:06 UTC (rev 3251)
@@ -1 +0,0 @@
-fails:Dispatch::Source of type PROC passes event mask as data
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100111/cc9f7f0e/attachment-0001.html>
More information about the macruby-changes
mailing list