[macruby-changes] [3109] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Dec 14 10:54:23 PST 2009
Revision: 3109
http://trac.macosforge.org/projects/ruby/changeset/3109
Author: ernest.prabhakar at gmail.com
Date: 2009-12-14 10:54:22 -0800 (Mon, 14 Dec 2009)
Log Message:
-----------
Added top-level svn:ignore for binaries, doc, and .installed.list
Modified Paths:
--------------
MacRuby/trunk/spec/macruby/core/gcd/queue_spec.rb
MacRuby/trunk/spec/macruby/core/gcd/semaphore_spec.rb
MacRuby/trunk/spec/macruby/core/gcd/source_spec_disabled.rb
MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/queue_tags.txt
MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/semaphore_tags.txt
Removed Paths:
-------------
MacRuby/trunk/spec/macruby/core/gcd_spec.rb
Property Changed:
----------------
MacRuby/trunk/
MacRuby/trunk/framework/
Property changes on: MacRuby/trunk
___________________________________________________________________
Modified: svn:ignore
- # Binary files.
*.o
.ext
miniruby
# Generated files.
include/ruby/config.h
dtrace.h
revision.h
parse.c
y.tab.c
lex.c
miniprelude.c
node_name.inc
prelude.c
rbconfig.rb
+ # Binary files.
*.o
.ext
miniruby
markgc
macruby
*.rbo
*.dylib
# Generated files.
.installed.list
doc
include/ruby/config.h
dtrace.h
revision.h
parse.c
y.tab.c
lex.c
miniprelude.c
node_name.inc
prelude.c
rbconfig.rb
Property changes on: MacRuby/trunk/framework
___________________________________________________________________
Added: svn:ignore
+ Info.plist
Modified: MacRuby/trunk/spec/macruby/core/gcd/queue_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/gcd/queue_spec.rb 2009-12-14 18:48:07 UTC (rev 3108)
+++ MacRuby/trunk/spec/macruby/core/gcd/queue_spec.rb 2009-12-14 18:54:22 UTC (rev 3109)
@@ -125,15 +125,21 @@
describe "Dispatch::Queue#after" do
it "accepts a given time (in seconds) and a block and yields it after" do
o = Dispatch::Queue.new('foo')
+ [1.0, 2, 0.9, 1.5].each do |test_time|
+
+ t = Time.now
+ o.after(test_time) { @i = 42 }
@i = 0
- t = Time.now
- o.after(0.2) { @i = 42 }
while @i == 0 do; end
+ @i.should == 42
t2 = Time.now - t
- t2.should >= 0.2
- t2.should < 0.5
- @i.should == 42
+ t2.should > test_time
+ t2.should < test_time*2
+ end
+ end
+ it "raises an ArgumentError if no time is given" do
+ o = Dispatch::Queue.new('foo')
lambda { o.after(nil) {} }.should raise_error(TypeError)
end
Modified: MacRuby/trunk/spec/macruby/core/gcd/semaphore_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/gcd/semaphore_spec.rb 2009-12-14 18:48:07 UTC (rev 3108)
+++ MacRuby/trunk/spec/macruby/core/gcd/semaphore_spec.rb 2009-12-14 18:54:22 UTC (rev 3109)
@@ -1,62 +1,70 @@
require File.dirname(__FILE__) + "/../../spec_helper"
if MACOSX_VERSION >= 10.6
-
+
describe "Dispatch::Semaphore" do
- it "returns an instance of Semaphore" do
- @sema = Dispatch::Semaphore.new 1
- @sema.should be_kind_of(Dispatch::Semaphore)
+ before :each do
+ @sema0 = Dispatch::Semaphore.new 0
+ @sema1 = Dispatch::Semaphore.new 1
+ @q = Dispatch::Queue.new('org.macruby.gcd_spec.semaphore')
end
- it "takes a non-negative Fixnum representing the width of the semaphore" do
- sema0 = Dispatch::Semaphore.new 0
- sema0.should be_kind_of(Dispatch::Semaphore)
- sema10 = Dispatch::Semaphore.new 10
- sema10.should be_kind_of(Dispatch::Semaphore)
+ it "returns an instance of Semaphore for non-negative counts" do
+ @sema0.should be_kind_of(Dispatch::Semaphore)
+ @sema1.should be_kind_of(Dispatch::Semaphore)
end
- it "raises an ArgumentError if the width isn't specified" do
+ it "raises an ArgumentError if the count isn't specified" do
lambda { Dispatch::Semaphore.new }.should raise_error(ArgumentError)
end
- it "raises an TypeError if a non-integer width is provided" do
+ it "raises a TypeError if a non-numeric count is provided" do
lambda { Dispatch::Semaphore.new :foo }.should raise_error(TypeError)
- lambda { Dispatch::Semaphore.new 3.5 }.should raise_error(TypeError)
+ lambda { Dispatch::Semaphore.new 3.5 }.should_not raise_error(TypeError)
+ lambda { Dispatch::Semaphore.new "3" }.should raise_error(TypeError)
end
- it "returns nil object if the specified width is less than zero" do
- sema = Dispatch::Semaphore.new -1
- sema.should.be_kind_of(NilClass)
+ it "raises an ArgumentError if the specified count is less than zero" do
+ lambda { Dispatch::Semaphore.new -1 }.should raise_error(ArgumentError)
end
- it "returns non-zero from 'signal' if it does wake a thread" do
- sema = Dispatch::Semaphore.new 0
- sema.signal.should_not == 0
- end
+ describe :wait do
+ it "always returns true with default timeout FOREVER" do
+ @sema1.wait.should == true
+ end
- it "returns zero from 'signal' if it does NOT wake a thread" do
- sema = Dispatch::Semaphore.new 1
- sema.signal.should == 0
- end
+ it "returns false if explicit timeout DOES expire" do
+ @sema0.wait(0.01).should == false
+ @sema1.wait(0.01).should == false
+ end
- it "returns non-zero from wait if explicit timeout does expire" do
- sema = Dispatch::Semaphore.new 0
- sema.wait(0.01).should_not == 0
- end
+ it "returns true if explicit timeout does NOT expire" do
+ @sema1.wait(Dispatch::TIME_FOREVER).should == true
+ q = Dispatch::Queue.new('foo')
+ q.async { @sema0.signal }
+ @sema0.wait(Dispatch::TIME_FOREVER).should == true
+ end
- it "returns zero from wait if explicit timeout does NOT expire" do
- sema = Dispatch::Semaphore.new 0
- q = Dispatch::Queue.new('foo')
- q.async {sema.signal.should_not == 0 }
- sema.wait(1).should == 0
+
+ describe :signal do
+ it "returns true if it does NOT wake a thread" do
+ @sema0.signal.should == true
+ @sema1.signal.should == true
+ end
+
+ it "returns false if it DOES wake a thread" do
+ @q.async do
+ sleep 0.1
+ @sema0.signal.should == false
+ @sema1.signal.should == false
+ end
+ @sema0.wait(Dispatch::TIME_FOREVER)
+ @sema1.wait(Dispatch::TIME_FOREVER)
+ end
+
end
- it "always returns zero from wait with default timeout FOREVER" do
- sema = Dispatch::Semaphore.new 0
- q = Dispatch::Queue.new('foo')
- q.async {sema.signal.should_not == 0 }
- sema.wait.should == 0
+
end
-
end
end
\ No newline at end of file
Modified: MacRuby/trunk/spec/macruby/core/gcd/source_spec_disabled.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/gcd/source_spec_disabled.rb 2009-12-14 18:48:07 UTC (rev 3108)
+++ MacRuby/trunk/spec/macruby/core/gcd/source_spec_disabled.rb 2009-12-14 18:54:22 UTC (rev 3109)
@@ -164,7 +164,7 @@
describe "on_timer" do
before :each do
- @src = @q.on_timer(Time.now, 0.1, 0.01) { |count| count.should >= 2 }
+ @src = @q.on_timer(0, 0.1, 0.01) { |count| count.should >= 2 }
end
after :each do
@@ -180,12 +180,12 @@
end
it "takes an event handler block" do
- lambda { @q.on_timer(Time.now, 0.1, 0.01) }.should raise_error(ArgumentError)
+ lambda { @q.on_timer(0, 0.1, 0.01) }.should raise_error(ArgumentError)
end
- it "takes start time, interval in seconds, and optional leeway" do
- lambda { @q.on_timer(Time.now, 0.1, 0.01) {} }.should_not raise_error(ArgumentError)
- lambda { @q.on_timer(Time.now, 0.1) {} }.should_not raise_error(ArgumentError)
+ it "takes delay, interval in seconds, and optional leeway" do
+ lambda { @q.on_timer(0, 0.1, 0.01) {} }.should_not raise_error(ArgumentError)
+ lambda { @q.on_timer(0, 0.1) {} }.should_not raise_error(ArgumentError)
lambda { @q.on_timer(0.1, Time.now) {} }.should raise_error(TypeError)
end
Deleted: MacRuby/trunk/spec/macruby/core/gcd_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/gcd_spec.rb 2009-12-14 18:48:07 UTC (rev 3108)
+++ MacRuby/trunk/spec/macruby/core/gcd_spec.rb 2009-12-14 18:54:22 UTC (rev 3109)
@@ -1,191 +0,0 @@
-require File.dirname(__FILE__) + "/../spec_helper"
-
-# TODO:
-# Dispatch::Queue.main.run
-# Dispatch::Group
-# Dispatch::Source
-
-if MACOSX_VERSION >= 10.6
- describe "Dispatch::Queue.concurrent" do
- it "returns an instance of Queue" do
- o = Dispatch::Queue.concurrent
- o.should be_kind_of(Dispatch::Queue)
- end
-
- it "can accept a symbol argument which represents the priority" do
- o = Dispatch::Queue.concurrent(:low)
- o.should be_kind_of(Dispatch::Queue)
-
- o = Dispatch::Queue.concurrent(:default)
- o.should be_kind_of(Dispatch::Queue)
-
- o = Dispatch::Queue.concurrent(:high)
- o.should be_kind_of(Dispatch::Queue)
-
- lambda { Dispatch::Queue.concurrent(42) }.should raise_error(TypeError)
- end
-
- it "raises an ArgumentError if the given argument is not a valid priority symbol" do
- lambda { Dispatch::Queue.concurrent(:foo) }.should raise_error(ArgumentError)
- end
-
- it "should return the same queue object across invocations" do
- a = Dispatch::Queue.concurrent(:low)
- b = Dispatch::Queue.concurrent(:low)
- a.should eql?(b)
- end
-
- it "raises a TypeError if the provided priority is not a symbol" do
- lambda { Dispatch::Queue.concurrent(42) }.should raise_error(TypeError)
- end
- end
-
- describe "Dispatch::Queue.current" do
- it "returns an instance of Queue" do
- o = Dispatch::Queue.current
- o.should be_kind_of(Dispatch::Queue)
- end
-
- it "should return the parent queue when inside an executing block" do
- q = Dispatch::Queue.new('org.macruby.rubyspecs.gcd.test')
- @q2 = nil
- q.async do
- @q2 = Dispatch::Queue.current
- end
- q.sync {}
- q.label.should == @q2.label
- end
- end
-
- describe "Dispatch::Queue.main" do
- it "returns an instance of Queue" do
- o = Dispatch::Queue.main
- o.should be_kind_of(Dispatch::Queue)
- end
- end
-
- describe "Dispatch::Queue.new" do
- it "accepts a name and returns an instance of Queue" do
- o = Dispatch::Queue.new('foo')
- o.should be_kind_of(Dispatch::Queue)
-
- lambda { Dispatch::Queue.new('foo', 42) }.should raise_error(ArgumentError)
- lambda { Dispatch::Queue.new(42) }.should raise_error(TypeError)
- end
- end
-
- describe "Dispatch::Queue#async" do
- it "accepts a block and yields it asynchronously" do
- o = Dispatch::Queue.new('foo')
- @i = 0
- o.async { @i = 42 }
- while @i == 0 do; end
- @i.should == 42
- end
-
- it "accepts a block and yields it asynchronously through a group if given" do
- o = Dispatch::Queue.new('foo')
- g = Dispatch::Group.new
- @i = 0
- o.async(g) { @i = 42 }
- g.wait
- @i.should == 42
-
- lambda { o.async(42) }.should raise_error(ArgumentError)
- end
-
- it "raises an ArgumentError if no block is given" do
- o = Dispatch::Queue.new('foo')
- lambda { o.async }.should raise_error(ArgumentError)
- end
- end
-
- describe "Dispatch::Queue#sync" do
- it "accepts a block and yields it synchronously" do
- o = Dispatch::Queue.new('foo')
- @i = 0
- o.sync { @i = 42 }
- @i.should == 42
- end
-
- it "raises an ArgumentError if no block is given" do
- o = Dispatch::Queue.new('foo')
- lambda { o.sync }.should raise_error(ArgumentError)
- end
- end
-
- describe "Dispatch::Queue#apply" do
- it "accepts an input size and a block and yields it as many times" do
- o = Dispatch::Queue.new('foo')
- @i = 0
- o.apply(10) { @i += 1 }
- @i.should == 10
- @i = 42
- o.apply(0) { @i += 1 }
- @i.should == 42
-
- lambda { o.apply(nil) {} }.should raise_error(TypeError)
- end
-
- it "raises an ArgumentError if no block is given" do
- o = Dispatch::Queue.new('foo')
- lambda { o.apply(42) }.should raise_error(ArgumentError)
- end
- end
-
- describe "Dispatch::Queue#after" do
- it "accepts a given time (in seconds) and a block and yields it after" do
- o = Dispatch::Queue.new('foo')
- @i = 0
- t = Time.now
- o.after(0.2) { @i = 42 }
- while @i == 0 do; end
- t2 = Time.now - t
- t2.should >= 0.2
- t2.should < 0.5
- @i.should == 42
-
- lambda { o.after(nil) {} }.should raise_error(TypeError)
- end
-
- it "raises an ArgumentError if no block is given" do
- o = Dispatch::Queue.new('foo')
- lambda { o.after(42) }.should raise_error(ArgumentError)
- end
- end
-
- describe "Dispatch::Queue#label" do
- it "returns the name of the queue" do
- o = Dispatch::Queue.new('foo')
- o.label.should == 'foo'
-
- o = Dispatch::Queue.main
- o.label.should == 'com.apple.main-thread'
- end
- end
-
- describe "Dispatch::Queue#suspend!" do
- it "suspends the queue which can be resumed by calling #resume!" do
- o = Dispatch::Queue.new('foo')
- o.async { sleep 1 }
- o.suspended?.should == false
- o.suspend!
- o.suspended?.should == true
- o.resume!
- o.suspended?.should == false
- end
- end
-
- describe "Dispatch::Group" do
- it "returns an instance of Group" do
- @group = Dispatch::Group.new
- @group.should be_kind_of(Dispatch::Group)
- end
-
- describe "#notify" do
- end
-
- describe "#wait" do
- end
- end
-end
Modified: MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/queue_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/queue_tags.txt 2009-12-14 18:48:07 UTC (rev 3108)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/queue_tags.txt 2009-12-14 18:54:22 UTC (rev 3109)
@@ -1,2 +1,2 @@
-fails:Dispatch::Queue.new raises an ArgumentError if not passed a string
+critical:Dispatch::Queue.new raises an ArgumentError if not passed a string
Modified: MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/semaphore_tags.txt
===================================================================
--- MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/semaphore_tags.txt 2009-12-14 18:48:07 UTC (rev 3108)
+++ MacRuby/trunk/spec/macruby/tags/macruby/core/gcd/semaphore_tags.txt 2009-12-14 18:54:22 UTC (rev 3109)
@@ -1,3 +1,7 @@
+<<<<<<< .mine
+critical:Dispatch::Semaphore raises an ArgumentError if the count isn't specified
+
+=======
fails:Dispatch::Semaphore raises an ArgumentError if the width isn't specified
fails:Dispatch::Semaphore raises an TypeError if a non-integer width is provided
fails:Dispatch::Semaphore returns nil object if the specified width is less than zero
@@ -4,3 +8,4 @@
fails:Dispatch::Semaphore returns non-zero from 'signal' if it does wake a thread
fails:Dispatch::Semaphore returns zero from wait if explicit timeout does NOT expire
fails:Dispatch::Semaphore always returns zero from wait with default timeout FOREVER
+>>>>>>> .r3106
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20091214/7eeaae8c/attachment-0001.html>
More information about the macruby-changes
mailing list