[macruby-changes] [3250] MacRuby/trunk/spec/macruby
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jan 11 17:33:05 PST 2010
Revision: 3250
http://trac.macosforge.org/projects/ruby/changeset/3250
Author: ernest.prabhakar at gmail.com
Date: 2010-01-11 17:33:04 -0800 (Mon, 11 Jan 2010)
Log Message:
-----------
Added Dispatch::Source:PROC specs, do not all 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-11 23:17:45 UTC (rev 3249)
+++ MacRuby/trunk/spec/macruby/core/gcd/source_spec.rb 2010-01-12 01:33:04 UTC (rev 3250)
@@ -63,12 +63,12 @@
src = Dispatch::Source.new(@type, 0, 0, @q) { }
src.should be_kind_of(Dispatch::Source)
end
-
+
it "should not be suspended" do
src = Dispatch::Source.new(@type, 0, 0, @q) { }
src.suspended?.should == false
end
-
+
it "fires event handler on merge" do
@i = 0
src = Dispatch::Source.new(@type, 0, 0, @q) {|s| @i = 42}
@@ -78,11 +78,14 @@
end
it "passes source to event handler" do
+ @flag = false
src = Dispatch::Source.new(@type, 0, 0, @q) do |source|
- source.should be_kind_of(Dispatch::Source)
+ @flag = (source.is_a? Dispatch::Source)
end
src << 42
@q.sync { }
+ @flag.should == true
+
end
it "passes data to source in event handler" do
@@ -115,13 +118,9 @@
@type = Dispatch::Source::DATA_OR
end
- it "returns an instance of Dispatch::Source" do
+ it "returns an active instance of Dispatch::Source" do
src = Dispatch::Source.new(@type, 0, 0, @q) { }
src.should be_kind_of(Dispatch::Source)
- end
-
- it "should not be suspended" do
- src = Dispatch::Source.new(@type, 0, 0, @q) { }
src.suspended?.should == false
end
@@ -132,14 +131,6 @@
@q.sync { }
@i.should == 42
end
-
- it "passes source to event handler" do
- src = Dispatch::Source.new(@type, 0, 0, @q) do |source|
- source.should be_kind_of(Dispatch::Source)
- end
- src << 42
- @q.sync { }
- end
it "coalesces data for source in event handler" do
@i = 0
@@ -158,25 +149,38 @@
describe :PROC do
before :each do
@type = Dispatch::Source::PROC
+ @mask = Dispatch::Source::PROC_SIGNAL
+ @signal = Signal.list["USR2"]
+ Signal.trap(@signal, "IGNORE")
end
- it "returns an instance of Dispatch::Source" do
- src = Dispatch::Source.new(@type, $$, 0, @q) { }
+ it "returns an active instance of Dispatch::Source" do
+ src = Dispatch::Source.new(@type, $$, @mask, @q) { }
src.should be_kind_of(Dispatch::Source)
+ src.suspended?.should == false
end
- end
- describe :SIGNAL do
- before :each do
- @type = Dispatch::Source::SIGNAL
- @signal = Signal.list["USR2"]
-
+ it "fires event handler on process event" do
+ @i = 0
+ src = Dispatch::Source.new(@type, $$, @mask, @q) { |s| @i += 42 }
+ Process.kill(@signal, $$) # send myself a SIGUSR2
+ @q.sync { }
+ @i.should == 42
end
-
- it "returns an instance of Dispatch::Source" do
- src = Dispatch::Source.new(@type, @signal, 0, @q) { }
- src.should be_kind_of(Dispatch::Source)
+
+ #The second spec always fails; can't send the same signal twice?!?
+ it "passes event mask as data" do
+ @i = 0
+ src = Dispatch::Source.new(@type, $$, @mask, @q) { |s| @i = s.data }
+ Process.kill(@signal, $$) # send myself a SIGUSR2
+ @q.sync { }
+ @i.should == @mask
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-11 23:17:45 UTC (rev 3249)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/source_tags.txt 2010-01-12 01:33:04 UTC (rev 3250)
@@ -0,0 +1 @@
+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/c33e9a9a/attachment-0001.html>
More information about the macruby-changes
mailing list