[macruby-changes] [1523] MacRuby/branches/experimental/spec/frozen
source_changes at macosforge.org
source_changes at macosforge.org
Sun May 3 06:28:23 PDT 2009
Revision: 1523
http://trac.macosforge.org/projects/ruby/changeset/1523
Author: eloy.de.enige at gmail.com
Date: 2009-05-03 06:28:23 -0700 (Sun, 03 May 2009)
Log Message:
-----------
Merged upstream changes upto b339f74be925a4b3ea844063920c6a3d4b435f32. Lots of 1.9 changes.
Modified Paths:
--------------
MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/frozen_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/push_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/reverse_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_subclass_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/metaclass_spec.rb
MacRuby/branches/experimental/spec/frozen/core/basicobject/shared/behavior.rb
MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb
MacRuby/branches/experimental/spec/frozen/core/kernel/sleep_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb
MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb
MacRuby/branches/experimental/spec/frozen/core/process/constants_spec.rb
MacRuby/branches/experimental/spec/frozen/core/regexp/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/core/signal/list_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb
MacRuby/branches/experimental/spec/frozen/core/thread/raise_spec.rb
MacRuby/branches/experimental/spec/frozen/core/thread/shared/exit.rb
MacRuby/branches/experimental/spec/frozen/core/thread/shared/wakeup.rb
MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb
MacRuby/branches/experimental/spec/frozen/core/threadgroup/list_spec.rb
MacRuby/branches/experimental/spec/frozen/language/alias_spec.rb
MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb
MacRuby/branches/experimental/spec/frozen/library/conditionvariable/broadcast_spec.rb
MacRuby/branches/experimental/spec/frozen/library/conditionvariable/signal_spec.rb
MacRuby/branches/experimental/spec/frozen/library/conditionvariable/wait_spec.rb
MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ipaddr/hton_spec.rb
MacRuby/branches/experimental/spec/frozen/library/ipaddr/to_s_spec.rb
MacRuby/branches/experimental/spec/frozen/library/matrix/new_spec.rb
MacRuby/branches/experimental/spec/frozen/library/mutex/lock_spec.rb
MacRuby/branches/experimental/spec/frozen/library/mutex/locked_spec.rb
MacRuby/branches/experimental/spec/frozen/library/mutex/synchronize_spec.rb
MacRuby/branches/experimental/spec/frozen/library/mutex/try_lock_spec.rb
MacRuby/branches/experimental/spec/frozen/library/mutex/unlock_spec.rb
MacRuby/branches/experimental/spec/frozen/library/pathname/absolute_spec.rb
MacRuby/branches/experimental/spec/frozen/library/pathname/hash_spec.rb
MacRuby/branches/experimental/spec/frozen/library/pathname/parent_spec.rb
MacRuby/branches/experimental/spec/frozen/library/pathname/relative_spec.rb
MacRuby/branches/experimental/spec/frozen/library/pathname/root_spec.rb
MacRuby/branches/experimental/spec/frozen/library/pathname/sub_spec.rb
MacRuby/branches/experimental/spec/frozen/library/set/hash_spec.rb
MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb
MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb
MacRuby/branches/experimental/spec/frozen/library/set/sortedset/hash_spec.rb
MacRuby/branches/experimental/spec/frozen/library/set/sortedset/initialize_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/recv_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/send_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/tcpserver/accept_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/tcpsocket/shared/new.rb
MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_nonblock_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/addr_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/path_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/peeraddr_spec.rb
MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/recvfrom_spec.rb
MacRuby/branches/experimental/spec/frozen/library/stringio/read_spec.rb
MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb
MacRuby/branches/experimental/spec/frozen/library/stringio/stringio_spec.rb
MacRuby/branches/experimental/spec/frozen/library/stringio/sysread_spec.rb
MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb
MacRuby/branches/experimental/spec/frozen/library/timeout/timeout_spec.rb
MacRuby/branches/experimental/spec/frozen/library/zlib/crc_table_spec.rb
MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
MacRuby/branches/experimental/spec/frozen/upstream
Added Paths:
-----------
MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_for_spec.rb
MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/
MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb
MacRuby/branches/experimental/spec/frozen/library/enumerator/to_enum_spec.rb
Modified: MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/array/fixtures/classes.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -20,9 +20,9 @@
end
def self.frozen_array
- @frozen_array ||= [1,2,3]
- @frozen_array.freeze
- @frozen_array
+ frozen_array = [1,2,3]
+ frozen_array.freeze
+ frozen_array
end
def self.recursive_array
Modified: MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/array/flatten_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -11,11 +11,21 @@
[ 1, 2, [3, [4, 5] ] ].flatten(1).should == [1, 2, 3, [4, 5]]
end
- it "returns self when the level of recursion is 0" do
- a = [ 1, 2, [3, [4, 5] ] ]
- a.flatten(0).should equal(a)
+ ruby_version_is ""..."1.9.2" do
+ it "returns self when the level of recursion is 0" do
+ a = [ 1, 2, [3, [4, 5] ] ]
+ a.flatten(0).should equal(a)
+ end
end
+ ruby_version_is "1.9.2" do
+ it "returns dup when the level of recursion is 0" do
+ a = [ 1, 2, [3, [4, 5] ] ]
+ a.flatten(0).should == a
+ a.flatten(0).should_not equal(a)
+ end
+ end
+
it "ignores negative levels" do
[ 1, 2, [ 3, 4, [5, 6] ] ].flatten(-1).should == [1, 2, 3, 4, 5, 6]
[ 1, 2, [ 3, 4, [5, 6] ] ].flatten(-10).should == [1, 2, 3, 4, 5, 6]
Modified: MacRuby/branches/experimental/spec/frozen/core/array/frozen_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/frozen_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/array/frozen_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -9,12 +9,21 @@
a.frozen?.should == true
end
- it "returns true if array is temporarily frozen while being sort!ed" do
- a = [1, 2, 3]
- a.sort! { |x,y| a.frozen?.should == true; x <=> y }
+ ruby_version_is "" .. "1.9" do
+ it "returns true for an array being sorted by #sort!" do
+ a = [1, 2, 3]
+ a.sort! { |x,y| a.frozen?.should == true; x <=> y }
+ end
end
- it "returns false for arrays being sorted (they aren't temporarily frozen)" do
+ ruby_version_is "1.9" do
+ it "returns false for an array being sorted by #sort!" do
+ a = [1, 2, 3]
+ a.sort! { |x,y| a.frozen?.should == false; x <=> y }
+ end
+ end
+
+ it "returns false for an array being sorted by #sort" do
a = [1, 2, 3]
a.sort { |x,y| a.frozen?.should == false; x <=> y }
end
Modified: MacRuby/branches/experimental/spec/frozen/core/array/push_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/push_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/array/push_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -25,11 +25,23 @@
array.push(:last).should == [1, 'two', 3.0, array, array, array, array, array, :last]
end
- it "raises a TypeError on a frozen array if modification takes place" do
- lambda { ArraySpecs.frozen_array.push(1) }.should raise_error(TypeError)
+ ruby_version_is "" .. "1.9" do
+ it "raises a TypeError on a frozen array if modification takes place" do
+ lambda { ArraySpecs.frozen_array.push(1) }.should raise_error(TypeError)
+ end
+
+ it "does not raise on a frozen array if no modification is made" do
+ ArraySpecs.frozen_array.push.should == [1, 2, 3]
+ end
end
- it "does not raise on a frozen array if no modification is made" do
- ArraySpecs.frozen_array.push.should == [1, 2, 3]
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError on a frozen array if modification takes place" do
+ lambda { ArraySpecs.frozen_array.push(1) }.should raise_error(RuntimeError)
+ end
+
+ it "Raise a RuntimeError on a frozen array if no modification is made too" do
+ lambda { ArraySpecs.frozen_array.push }.should raise_error(RuntimeError)
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/array/reverse_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/reverse_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/array/reverse_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -36,7 +36,15 @@
array.reverse!.should == [array, array, array, array, array, 3.0, 'two', 1]
end
- it "raises a TypeError on a frozen array" do
- lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(TypeError)
+ ruby_version_is "" .. "1.9" do
+ it "raises a TypeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError on a frozen array" do
+ lambda { ArraySpecs.frozen_array.reverse! }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/array/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/to_s_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/array/to_s_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -14,6 +14,17 @@
$, = old
end
end
+
+ it "returns '[...]' for an empty array embedded in itself" do
+ ArraySpecs.empty_recursive_array.to_s.should == "[...]"
+ end
+
+ ruby_bug "[ruby-dev:37019]", "1.8.6.319" do
+ it "returns '[...]' for the embedded array in a recursive array" do
+ a = [1, 2, 3]; a << a
+ a.to_s.should == "123[...]"
+ end
+ end
end
ruby_version_is "1.9" do
@@ -21,29 +32,14 @@
a = [1, 2, 3, 4]
a.to_s.should == a.inspect
end
- end
- ruby_version_is "" .. "1.8.6.319" do
- it "properly handles recursive arrays" do
- ArraySpecs.empty_recursive_array.to_s.should == "[...]"
- a = [1, 2, 3]; a << a
- a.to_s.should == "123123[...]"
- end
- end
+ it "is equivalent to Array#inspect in a recursive array" do
+ a = [1, 2, 3, 4]; a << a
+ a.to_s.should == a.inspect
- ruby_version_is "1.8.6.320" ... "1.9" do
- it "properly handles recursive arrays" do
- ArraySpecs.empty_recursive_array.to_s.should == "[...]"
- a = [1, 2, 3]; a << a
- a.to_s.should == "123[...]"
+ a = ArraySpecs.empty_recursive_array
+ a.to_s.should == "[[...]]"
+ a.inspect == "[[...]]"
end
end
-
- ruby_version_is "1.9" do
- it "properly handles recursive arrays" do
- ArraySpecs.empty_recursive_array.to_s.should == "[...]"
- a = [1, 2, 3]; a << a
- a.to_s.should == "123123[...]"
- end
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_class_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,7 +1,7 @@
require File::join( File::dirname(__FILE__), %w{ .. .. spec_helper } )
-require File::join( File::dirname(__FILE__), %w{ shared behavior } )
-ruby_version_is "1.9".."1.9.9" do
+ruby_version_is "1.9" do
+ require File::join( File::dirname(__FILE__), %w{ shared behavior } )
describe "BasicObject class" do
Modified: MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,7 +1,7 @@
require File::join( File::dirname(__FILE__), %w{ .. .. spec_helper } )
-require File::join( File::dirname(__FILE__), %w{ shared behavior } )
-ruby_version_is "1.9".."1.9.9" do
+ruby_version_is "1.9" do
+ require File::join( File::dirname(__FILE__), %w{ shared behavior } )
describe "BasicObject behaves" do
extend BasicObjectBehavior
Modified: MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_subclass_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_subclass_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/basic_object_subclass_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,7 +1,8 @@
require File::join( File::dirname(__FILE__), %w{ .. .. spec_helper } )
-require File::join( File::dirname(__FILE__), %w{ shared behavior } )
-ruby_version_is "1.9".."1.9.9" do
+ruby_version_is "1.9" do
+ require File::join( File::dirname(__FILE__), %w{ shared behavior } )
+
MyBO = Class::new BasicObject
describe "BasicObject's subclasses behave" do
Modified: MacRuby/branches/experimental/spec/frozen/core/basicobject/metaclass_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/metaclass_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/metaclass_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,7 +1,7 @@
require File::join( File::dirname(__FILE__), %w{ .. .. spec_helper } )
-require File::join( File::dirname(__FILE__), %w{ shared behavior } )
-ruby_version_is "1.9".."1.9.9" do
+ruby_version_is "1.9" do
+ require File::join( File::dirname(__FILE__), %w{ shared behavior } )
describe "BasicObject#metaclass" do
foo = metafoo = nil
Modified: MacRuby/branches/experimental/spec/frozen/core/basicobject/shared/behavior.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/basicobject/shared/behavior.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/basicobject/shared/behavior.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -2,9 +2,11 @@
def private_features
[ :initialize, :method_missing, :singleton_method_added, :singleton_method_removed, :singleton_method_undefined ]
end
+
def protected_features
[]
end
+
def public_features
[ :!, :!=, :==, :__send__, :equal?, :instance_eval, :instance_exec ]
end
Modified: MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/file/join_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -65,51 +65,14 @@
File.join("usr", "", "/bin").should == "usr/bin"
File.join("usr/", "", "/bin").should == "usr/bin"
end
-
- # TODO: Repeating items in recursive array seems like a bug.
- it "handles recursive arrays" do
- parts = []
- parts << parts
- File.join(parts).should == '[...]'
- parts = ["one", "two"]
- parts << parts
- File.join(parts).should == 'one/two/one/two/[...]'
-
- parts << "three"
- parts << "four"
- File.join(parts).should == 'one/two/one/two/[...]/three/four/three/four'
-
- parts = [["one", "two"], ["three", "four"]]
- parts << parts
- File.join(parts).should == 'one/two/three/four/one/two/three/four/[...]'
-
- a = ['a']
- a << a
- File.join(a).should == 'a/a/[...]'
- File.join([a]).should == 'a/a/[...]'
-
- a = ['a']
- b = ['b']
- a << b
- b << a
- File.join(a).should == "a/b/[...]"
-
- a = []
- b = []
- a << b
- b << a
- File.join(a).should == '[...]'
-
- a = ['a']
- a << a
- File.join( a ).should == "a/a/[...]"
- File.join( [a] ).should == "a/a/[...]"
- File.join([[a]]).should == "a/a/[...]"
- File.join( a, 'b' ).should == "a/a/[...]/b"
- File.join( [a, 'b'] ).should == "a/a/[...]/b"
- File.join([[a, 'b']]).should == "a/a/[...]/b"
- File.join([[a], 'b']).should == "a/a/[...]/b"
+ # TODO: See MRI svn r23306. Add patchlevel when there is a release.
+ ruby_bug "redmine #1418", "1.8.8" do
+ it "raises an ArgumentError if passed a recursive array" do
+ a = ["a"]
+ a << a
+ lambda { File.join a }.should raise_error(ArgumentError)
+ end
end
it "doesn't remove File::SEPARATOR from the middle of arguments" do
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/loop_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -31,8 +31,27 @@
it "raises a LocalJumpError if no block given" do
lambda { loop }.should raise_error(LocalJumpError)
end
-end
-describe "Kernel#loop" do
- it "needs to be reviewed for spec completeness"
+ ruby_version_is "1.9" do
+ it "rescues StopIteration" do
+ n = 42
+ loop do
+ raise StopIteration
+ end
+ 42.should == 42
+ end
+
+ it "rescues StopIteration's subclasses" do
+ finish = Class::new StopIteration
+ n = 42
+ loop do
+ raise finish
+ end
+ 42.should == 42
+ end
+
+ it "does not rescue other errors" do
+ lambda{ loop do raise StandardError end }.should raise_error( StandardError )
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/kernel/sleep_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/kernel/sleep_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/kernel/sleep_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -32,7 +32,7 @@
end
lock.receive.should == :ready
# wait until the thread has gone to sleep
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
t.run
t.value.should == 5
end
Modified: MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/module/instance_method_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -35,11 +35,24 @@
@mod_um.inspect.should =~ /\bModuleSpecs::InstanceMethChild\b/
end
+ it "raises an ArgumentError if passed a Fixnum that is not a symbol" do
+ lambda { Object.instance_method(0) }.should raise_error(ArgumentError)
+ end
+
it "raises a TypeError if the given name is not a string/symbol" do
lambda { Object.instance_method(nil) }.should raise_error(TypeError)
lambda { Object.instance_method(mock('x')) }.should raise_error(TypeError)
end
+ it "raises a NameError if the method has been undefined" do
+ ModuleSpecs::InstanceMethChild.send :undef_method, :foo
+ um = ModuleSpecs::InstanceMeth.instance_method(:foo)
+ um.should == @parent_um
+ lambda do
+ ModuleSpecs::InstanceMethChild.instance_method(:foo)
+ end.should raise_error(NameError)
+ end
+
it "raises a NameError if the given method doesn't exist" do
lambda { Object.instance_method(:missing) }.should raise_error(NameError)
lambda { Object.instance_method(:missing) }.should_not raise_error(NoMethodError)
Modified: MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/module/private_method_defined_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -31,24 +31,32 @@
ModuleSpecs::CountsMixin.private_method_defined?(:private_3).should == true
end
- not_compliant_on :rubinius do
- it "raises an ArgumentError if passed a Fixnum" do
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(1)
- }.should raise_error(ArgumentError)
- end
+ it "raises an ArgumentError if passed a Fixnum" do
+ lambda {
+ ModuleSpecs::CountsMixin.private_method_defined?(1)
+ }.should raise_error(ArgumentError)
+ end
- it "raises a TypeError if not passed a Symbol" do
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(nil)
- }.should raise_error(TypeError)
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(false)
- }.should raise_error(TypeError)
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(mock('x'))
- }.should raise_error(TypeError)
+ it "raises a TypeError if passed nil" do
+ lambda {
+ ModuleSpecs::CountsMixin.private_method_defined?(nil)
+ }.should raise_error(TypeError)
+ end
+ it "raises a TypeError if passed false" do
+ lambda {
+ ModuleSpecs::CountsMixin.private_method_defined?(false)
+ }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError if passed an object that does not defined #to_str" do
+ lambda {
+ ModuleSpecs::CountsMixin.private_method_defined?(mock('x'))
+ }.should raise_error(TypeError)
+ end
+
+ not_compliant_on :rubinius do
+ it "raises a TypeError if passed an object that defines #to_sym" do
sym = mock('symbol')
def sym.to_sym() :private_3 end
lambda {
@@ -57,26 +65,18 @@
end
end
- it "accepts any argument that is a String type" do
+ deviates_on :rubinius do
+ it "calls #to_sym to coerce the passed object to a Symbol" do
+ sym = mock('symbol')
+ def sym.to_sym() :private_3 end
+
+ ModuleSpecs::CountsMixin.private_method_defined?(sym).should be_true
+ end
+ end
+
+ it "calls #to_str to coerce the passed object to a String" do
str = mock('string')
def str.to_str() 'private_3' end
ModuleSpecs::CountsMixin.private_method_defined?(str).should == true
end
-
- deviates_on :rubinius do
- it "raises a TypeError if not passed a String type" do
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(1)
- }.should raise_error(TypeError)
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(nil)
- }.should raise_error(TypeError)
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(false)
- }.should raise_error(TypeError)
- lambda {
- ModuleSpecs::CountsMixin.private_method_defined?(mock('x'))
- }.should raise_error(TypeError)
- end
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/process/constants_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/process/constants_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/process/constants_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,7 +1,7 @@
describe "Process::Constants" do
platform_is :os => [:darwin, :netbsd, :freebsd] do
- it "should have the correct constant values on BSD-like systems" do
+ it "has the correct constant values on BSD-like systems" do
Process::WNOHANG.should == 1
Process::WUNTRACED.should == 2
Process::PRIO_PROCESS.should == 0
@@ -21,7 +21,7 @@
end
platform_is :os => [:darwin] do
- it "should have the correct constant values on Darwin" do
+ it "has the correct constant values on Darwin" do
Process::RLIM_SAVED_MAX.should == 9223372036854775807
Process::RLIM_SAVED_CUR.should == 9223372036854775807
Process::RLIMIT_AS.should == 5
@@ -29,7 +29,7 @@
end
platform_is :os => [:linux] do
- it "should have the correct constant values on Linux" do
+ it "has the correct constant values on Linux" do
Process::WNOHANG.should == 1
Process::WUNTRACED.should == 2
Process::PRIO_PROCESS.should == 0
Modified: MacRuby/branches/experimental/spec/frozen/core/regexp/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/regexp/to_s_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/regexp/to_s_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,24 +1,24 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe "Regexp#to_s" do
- it "should display options if included" do
+ it "displays options if included" do
/abc/mxi.to_s.should == "(?mix:abc)"
end
- it "should show non-included options after a - sign" do
+ it "shows non-included options after a - sign" do
/abc/i.to_s.should == "(?i-mx:abc)"
end
- it "should show all options as excluded if none are selected" do
+ it "shows all options as excluded if none are selected" do
/abc/.to_s.should == "(?-mix:abc)"
end
- it "should show the pattern after the options" do
+ it "shows the pattern after the options" do
/ab+c/mix.to_s.should == "(?mix:ab+c)"
/xyz/.to_s.should == "(?-mix:xyz)"
end
- it "should display groups with options" do
+ it "displays groups with options" do
/(?ix:foo)(?m:bar)/.to_s.should == "(?-mix:(?ix:foo)(?m:bar))"
/(?ix:foo)bar/m.to_s.should == "(?m-ix:(?ix:foo)bar)"
end
Modified: MacRuby/branches/experimental/spec/frozen/core/signal/list_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/signal/list_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/signal/list_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -53,12 +53,12 @@
end
if Signal.list["CHLD"]
- it "should redefine CLD with CHLD if defined" do
+ it "redefines CLD with CHLD if defined" do
Signal.list["CLD"].should == Signal.list["CHLD"]
end
end
- it "should contain the EXIT key with a value of zero" do
+ it "includes the EXIT key with a value of zero" do
Signal.list["EXIT"].should == 0
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/critical_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -32,7 +32,7 @@
it "does not change status of other existing threads" do
t = ThreadSpecs.create_critical_thread { ScratchPad.record Thread.main.status }
- Thread.pass while t.status != false
+ Thread.pass while t.status and t.status != false
ScratchPad.recorded.should == "run"
end
@@ -71,20 +71,20 @@
it "defers exit" do
critical_thread = ThreadSpecs.create_and_kill_critical_thread()
- Thread.pass while critical_thread.status != false
+ Thread.pass while critical_thread.status
ScratchPad.recorded.should == "status=aborting"
end
it "defers exit until Thread.pass" do
critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
- Thread.pass while critical_thread.status != false
+ Thread.pass while critical_thread.status
ScratchPad.recorded.should == nil
end
not_compliant_on(:ironruby) do # requires green threads so that another thread can be scheduled when the critical thread is killed
it "is not reset if the critical thread is killed" do
critical_thread = ThreadSpecs.create_and_kill_critical_thread(true)
- Thread.pass while critical_thread.status != false
+ Thread.pass while critical_thread.status
Thread.critical.should == true
Thread.critical = false
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/fixtures/classes.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -57,7 +57,7 @@
def self.status_of_running_thread
t = running_thread
- Thread.pass while t.alive? && t.status != "run"
+ Thread.pass while t.status and t.status != "run"
status = Status.new t
t.kill
t.join
@@ -72,7 +72,7 @@
def self.status_of_sleeping_thread
t = sleeping_thread
- Thread.pass until t.status == 'sleep'
+ Thread.pass while t.status and t.status != 'sleep'
status = Status.new t
t.run
t.join
@@ -83,7 +83,7 @@
m = Mutex.new
m.lock
t = Thread.new { m.lock }
- Thread.pass until t.status == 'sleep'
+ Thread.pass while t.status and t.status != 'sleep'
status = Status.new t
m.unlock
t.join
@@ -103,7 +103,7 @@
def self.status_of_killed_thread
t = Thread.new { sleep }
- Thread.pass until t.status == 'sleep'
+ Thread.pass while t.status and t.status != 'sleep'
t.kill
t.join
Status.new t
@@ -127,7 +127,7 @@
def self.status_of_dying_sleeping_thread
t = dying_thread_ensures { Thread.stop; }
- Thread.pass until t.status == 'sleep'
+ Thread.pass while t.status and t.status != 'sleep'
status = Status.new t
t.wakeup
t.join
@@ -165,10 +165,10 @@
end
def self.wakeup_dying_sleeping_thread(kill_method_name=:kill)
- thread = ThreadSpecs.dying_thread_ensures(kill_method_name) { yield }
- Thread.pass until thread.status == "sleep"
- thread.wakeup
- thread.join
+ t = ThreadSpecs.dying_thread_ensures(kill_method_name) { yield }
+ Thread.pass while t.status and t.status != 'sleep'
+ t.wakeup
+ t.join
end
def self.critical_is_reset
@@ -225,7 +225,7 @@
critical_thread[:thread_specs] = 101
if isThreadSleep or isThreadStop
# Thread#wakeup calls are not queued up. So we need to ensure that the thread is sleeping before calling wakeup
- Thread.pass while critical_thread.status != "sleep"
+ Thread.pass while critical_thread.status and critical_thread.status != "sleep"
critical_thread.wakeup
end
end
@@ -240,12 +240,12 @@
@@after_first_sleep = false
critical_thread = Thread.new do
- Thread.pass while Thread.main.status != "sleep"
+ Thread.pass while Thread.main.status and Thread.main.status != "sleep"
critical_thread1()
Thread.main.wakeup
yield
Thread.pass while @@after_first_sleep != true # Need to ensure that the next statement does not see the first sleep itself
- Thread.pass while Thread.main.status != "sleep"
+ Thread.pass while Thread.main.status and Thread.main.status != "sleep"
critical_thread2(isThreadStop)
Thread.main.wakeup
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/raise_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/raise_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/raise_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -15,7 +15,7 @@
before :each do
ScratchPad.clear
@thr = ThreadSpecs.sleeping_thread
- Thread.pass while (@thr.alive? && @thr.status != "sleep")
+ Thread.pass while @thr.status and @thr.status != "sleep"
end
after :each do
@@ -59,7 +59,7 @@
end
end
- Thread.pass while t.status != "sleep"
+ Thread.pass while t.status and t.status != "sleep"
t.raise
lambda {t.value}.should raise_error(ZeroDivisionError)
t.kill
@@ -70,7 +70,7 @@
before :each do
ScratchPad.clear
@thr = ThreadSpecs.running_thread
- Thread.pass while (@thr.alive? && @thr.status != "run")
+ Thread.pass while @thr.status and @thr.status != "run"
end
after :each do
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/shared/exit.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/shared/exit.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/shared/exit.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -8,7 +8,7 @@
sleep
ScratchPad.record :after_sleep
end
- Thread.pass while sleeping_thread.status != "sleep"
+ Thread.pass while sleeping_thread.status and sleeping_thread.status != "sleep"
sleeping_thread.send(@method)
sleeping_thread.join
ScratchPad.recorded.should == nil
@@ -43,12 +43,12 @@
sleep
ensure
ScratchPad << :outer_ensure_clause
- Thread.pass until inner.status == "sleep"
+ Thread.pass while inner.status and inner.status != "sleep"
inner.send(@method)
inner.join
end
end
- Thread.pass until outer.status == "sleep"
+ Thread.pass while outer.status and outer.status != "sleep"
outer.send(@method)
outer.join
ScratchPad.recorded.should include(:inner_ensure_clause)
@@ -77,7 +77,7 @@
it "killing dying sleeping thread wakes up thread" do
t = ThreadSpecs.dying_thread_ensures { Thread.stop; ScratchPad.record :after_stop }
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
t.send(@method)
t.join
ScratchPad.recorded.should == :after_stop
@@ -157,7 +157,7 @@
it "does not deadlock when called from within the thread while being joined from without" do
100.times do
t = Thread.new { Thread.stop; Thread.current.send(@method) }
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
t.wakeup.should == t
t.join.should == t
end
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/shared/wakeup.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/shared/wakeup.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/shared/wakeup.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -21,12 +21,12 @@
exit_loop = true
- Thread.pass while t.status != "sleep"
+ Thread.pass while t.status and t.status != "sleep"
after_sleep1.should == false # t should be blocked on the first sleep
t.send(@method)
Thread.pass while after_sleep1 != true
- Thread.pass while t.status != "sleep"
+ Thread.pass while t.status and t.status != "sleep"
after_sleep2.should == false # t should be blocked on the second sleep
t.send(@method)
Thread.pass while after_sleep2 != true
Modified: MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/thread/stop_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -4,7 +4,7 @@
describe "Thread.stop" do
it "causes the current thread to sleep indefinitely" do
t = Thread.new { Thread.stop; 5 }
- Thread.pass until t.status == 'sleep'
+ Thread.pass while t.status and t.status != 'sleep'
t.status.should == 'sleep'
t.run
t.value.should == 5
@@ -12,7 +12,7 @@
it "resets Thread.critical to false" do
t = Thread.new { Thread.critical = true; Thread.stop }
- Thread.pass until t.status == 'sleep'
+ Thread.pass while t.status and t.status != 'sleep'
Thread.critical.should == false
t.run
t.join
Modified: MacRuby/branches/experimental/spec/frozen/core/threadgroup/list_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/threadgroup/list_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/core/threadgroup/list_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -16,8 +16,8 @@
tg.add(th2)
(tg.list & [th1, th2]).should include(th1, th2)
- Thread.pass until th1.status == 'sleep' || !th1.alive?
- Thread.pass until th2.status == 'sleep' || !th2.alive?
+ Thread.pass while th1.status and th1.status != 'sleep'
+ Thread.pass while th2.status and th2.status != 'sleep'
th1.run; th1.join
th2.run; th2.join
end
Modified: MacRuby/branches/experimental/spec/frozen/language/alias_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/alias_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/language/alias_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -81,4 +81,66 @@
@obj.baz = 5
@obj.abaz.should == 5
end
+
+ it "operates on methods with splat arguments" do
+ class AliasObject2;end
+ AliasObject2.class_eval do
+ def test(*args)
+ 4
+ end
+ def test_with_check(*args)
+ test_without_check(*args)
+ end
+ alias test_without_check test
+ alias test test_with_check
+ end
+ AliasObject2.new.test(1,2,3,4,5).should == 4
+ end
+
+ it "operates on methods with splat arguments on eigenclasses" do
+ @meta.class_eval do
+ def test(*args)
+ 4
+ end
+ def test_with_check(*args)
+ test_without_check(*args)
+ end
+ alias test_without_check test
+ alias test test_with_check
+ end
+ @obj.test(1,2,3,4,5).should == 4
+ end
+
+ it "operates on methods with splat arguments defined in a superclass" do
+ class AliasObject3;end
+ class Sub3 < AliasObject3;end
+ AliasObject3.class_eval do
+ def test(*args)
+ 4
+ end
+ def test_with_check(*args)
+ test_without_check(*args)
+ end
+ end
+ Sub3.class_eval do
+ alias test_without_check test
+ alias test test_with_check
+ end
+ Sub3.new.test(1,2,3,4,5).should == 4
+ end
+
+ it "operates on methods with splat arguments defined in a superclass using text block for class eval" do
+ class Sub < AliasObject;end
+ AliasObject.class_eval <<-code
+ def test(*args)
+ 4
+ end
+ def test_with_check(*args)
+ test_without_check(*args)
+ end
+ alias test_without_check test
+ alias test test_with_check
+ code
+ Sub.new.test("testing").should == 4
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/language/eigenclass_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -30,6 +30,22 @@
cls.should_not equal(Object)
mock.is_a?(cls).should be_true
end
+
+ it "is a Class for classes" do
+ cls = class << ClassSpecs::A;self;end
+ cls.is_a?(Class).should be_true
+ end
+
+ it "inherits from Class for classes" do
+ temp = []
+ cls = class << Object;self;end
+ sc = cls
+ until sc.nil? || sc.superclass == sc
+ temp << sc
+ sc = sc.superclass
+ end
+ temp.should include(Class)
+ end
ruby_version_is "1.9" do
it "is a metaclass for classes" do
Modified: MacRuby/branches/experimental/spec/frozen/library/conditionvariable/broadcast_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/conditionvariable/broadcast_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/conditionvariable/broadcast_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -17,7 +17,7 @@
end
# ensures that th grabs m before current thread
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
m.synchronize { cv.broadcast }.should == cv
Modified: MacRuby/branches/experimental/spec/frozen/library/conditionvariable/signal_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/conditionvariable/signal_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/conditionvariable/signal_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -17,7 +17,7 @@
end
# ensures that th grabs m before current thread
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
m.synchronize { cv.signal }.should == cv
Modified: MacRuby/branches/experimental/spec/frozen/library/conditionvariable/wait_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/conditionvariable/wait_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/conditionvariable/wait_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -13,7 +13,7 @@
end
# ensures that th grabs m before current thread
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
m.synchronize { cv.signal }
th.join
Added: MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_for_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_for_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/enum_for_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -0,0 +1,6 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/enum_for'
+
+describe "#enum_for" do
+ it_behaves_like :enumerator_enum_for, :enum_for
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/new_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -15,4 +15,8 @@
it "creates a new custom enumerator that runs correctly" do
Enumerable::Enumerator.new(1, :upto, 3).map{|x|x}.should == [1,2,3]
end
+
+ it "aliases the second argument to :each" do
+ Enumerable::Enumerator.new(1..2).to_a.should == Enumerable::Enumerator.new(1..2, :each).to_a
+ end
end
Added: MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/shared/enum_for.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -0,0 +1,16 @@
+require 'enumerator'
+
+describe :enumerator_enum_for, :shared => true do
+ it "is defined in Kernel" do
+ Kernel.method_defined?(@method).should be_true
+ end
+
+ it "returns a new enumerator" do
+ "abc".send(@method).should be_kind_of(Enumerable::Enumerator)
+ end
+
+ it "defaults the first argument to :each" do
+ enum = [1,2].send(@method, :each)
+ enum.map { |v| v }.should == [1,2].each { |v| v }
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/library/enumerator/to_enum_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/enumerator/to_enum_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/library/enumerator/to_enum_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -0,0 +1,6 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/enum_for'
+
+describe "#to_enum" do
+ it_behaves_like :enumerator_enum_for, :enum_for
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/ipaddr/hton_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ipaddr/hton_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/ipaddr/hton_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,7 +3,7 @@
describe 'IPAddr#hton' do
- it 'should be able to convert IPAddr to network byte order' do
+ it 'converts IPAddr to network byte order' do
addr = ''
IPAddr.new("1234:5678:9abc:def0:1234:5678:9abc:def0").hton.each_byte do |c|
addr += sprintf("%02x", c)
@@ -20,11 +20,11 @@
describe 'IPAddr#new_ntoh' do
- it "should be able to create a new IPAddr using hton notation" do
+ it "creates a new IPAddr using hton notation" do
a = IPAddr.new("3ffe:505:2::")
IPAddr.new_ntoh(a.hton).to_s.should == "3ffe:505:2::"
a = IPAddr.new("192.168.2.1")
IPAddr.new_ntoh(a.hton).to_s.should == "192.168.2.1"
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/ipaddr/to_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/ipaddr/to_s_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/ipaddr/to_s_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,7 +3,7 @@
describe "IPAddr#to_s" do
- it 'it should display IPAddr using short notation' do
+ it 'displays IPAddr using short notation' do
IPAddr.new("0:0:0:1::").to_s.should == "0:0:0:1::"
IPAddr.new("2001:200:300::/48").to_s.should == "2001:200:300::"
IPAddr.new("[2001:200:300::]/48").to_s.should == "2001:200:300::"
@@ -13,9 +13,8 @@
end
describe "IPAddr#to_string" do
-
- it "should be able to display an IPAddr using full notation" do
+ it "displays an IPAddr using full notation" do
IPAddr.new("3ffe:505:2::1").to_string.should == "3ffe:0505:0002:0000:0000:0000:0000:0001"
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/matrix/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/matrix/new_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/matrix/new_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,7 +3,7 @@
describe "Matrix#new" do
- it "should a Matrix" do
+ it "returns a Matrix" do
lambda { Matrix.new }.should raise_error
end
Modified: MacRuby/branches/experimental/spec/frozen/library/mutex/lock_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/mutex/lock_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/mutex/lock_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -2,13 +2,13 @@
require 'thread'
describe "Mutex#lock" do
- it "should return self" do
+ it "returns self" do
m = Mutex.new
m.lock.should == m
m.unlock
end
- it "should wait if the lock is not available" do
+ it "waits if the lock is not available" do
m = Mutex.new
m.lock
@@ -19,7 +19,7 @@
v = 1
end
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
v.should == 0
m.unlock
Modified: MacRuby/branches/experimental/spec/frozen/library/mutex/locked_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/mutex/locked_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/mutex/locked_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -2,18 +2,18 @@
require 'thread'
describe "Mutex#locked?" do
- it "should return true if locked" do
+ it "returns true if locked" do
m = Mutex.new
m.lock
m.locked?.should be_true
end
- it "should return false if unlocked" do
+ it "returns false if unlocked" do
m = Mutex.new
m.locked?.should be_false
end
- it "should return the status of the lock" do
+ it "returns the status of the lock" do
m1 = Mutex.new
m2 = Mutex.new
@@ -24,7 +24,7 @@
m2.lock
end
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
m1.locked?.should be_true
m2.unlock # release th
Modified: MacRuby/branches/experimental/spec/frozen/library/mutex/synchronize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/mutex/synchronize_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/mutex/synchronize_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -16,7 +16,7 @@
end.should raise_error(Exception)
end
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
m1.locked?.should be_true
m2.unlock
Modified: MacRuby/branches/experimental/spec/frozen/library/mutex/try_lock_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/mutex/try_lock_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/mutex/try_lock_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -2,12 +2,12 @@
require 'thread'
describe "Mutex#try_lock" do
- it "should return true if lock can be aquired immediately" do
+ it "returns true if lock can be aquired immediately" do
m = Mutex.new
m.try_lock.should be_true
end
- it "should return false if lock can not be aquired immediately" do
+ it "returns false if lock can not be aquired immediately" do
m1 = Mutex.new
m2 = Mutex.new
@@ -17,7 +17,7 @@
m2.lock
end
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
# th owns m1 so try_lock should return false
m1.try_lock.should be_false
Modified: MacRuby/branches/experimental/spec/frozen/library/mutex/unlock_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/mutex/unlock_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/mutex/unlock_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -2,12 +2,12 @@
require 'thread'
describe "Mutex#unlock" do
- it "should raise ThreadError unless Mutex is locked" do
+ it "raises ThreadError unless Mutex is locked" do
mutex = Mutex.new
lambda { mutex.unlock }.should raise_error(ThreadError)
end
- it "should raise ThreadError unless thread owns Mutex" do
+ it "raises ThreadError unless thread owns Mutex" do
mutex = Mutex.new
wait = Mutex.new
wait.lock
@@ -17,7 +17,7 @@
end
# avoid race on mutex.lock
- Thread.pass until th.status == "sleep"
+ Thread.pass while th.status and th.status != "sleep"
lambda { mutex.unlock }.should raise_error(ThreadError)
@@ -25,7 +25,7 @@
th.join
end
- it "should return nil if successful" do
+ it "returns nil if successful" do
mutex = Mutex.new
mutex.lock
mutex.unlock.should.be_nil
Modified: MacRuby/branches/experimental/spec/frozen/library/pathname/absolute_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/pathname/absolute_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/pathname/absolute_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,19 +3,19 @@
describe "Pathname#absolute?" do
- it "should return true for the root directory" do
+ it "returns true for the root directory" do
Pathname.new('/').absolute?.should == true
end
- it "should return true for a dir starting with a slash" do
+ it "returns true for a dir starting with a slash" do
Pathname.new('/usr/local/bin').absolute?.should == true
end
- it "should return false for a dir not starting with a slash" do
+ it "returns false for a dir not starting with a slash" do
Pathname.new('fish').absolute?.should == false
end
- it "should return false for a dir not starting with a slash" do
+ it "returns false for a dir not starting with a slash" do
Pathname.new('fish/dog/cow').absolute?.should == false
end
Modified: MacRuby/branches/experimental/spec/frozen/library/pathname/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/pathname/hash_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/pathname/hash_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,11 +3,11 @@
describe "Pathname#hash" do
- it "should equal the hash of the pathname" do
+ it "is equal to the hash of the pathname" do
Pathname.new('/usr/local/bin/').hash.should == '/usr/local/bin/'.hash
end
- it "should not equal the hash of a different pathname" do
+ it "is not equal the hash of a different pathname" do
Pathname.new('/usr/local/bin/').hash.should_not == '/usr/bin/'.hash
end
Modified: MacRuby/branches/experimental/spec/frozen/library/pathname/parent_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/pathname/parent_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/pathname/parent_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,15 +3,15 @@
describe "Pathname#parent" do
- it "should have parent of root as root" do
+ it "has parent of root as root" do
Pathname.new('/').parent.to_s.should == '/'
end
- it "should have parent of /usr/ as root" do
+ it "has parent of /usr/ as root" do
Pathname.new('/usr/').parent.to_s.should == '/'
end
- it "should have parent of /usr/local as root" do
+ it "has parent of /usr/local as root" do
Pathname.new('/usr/local').parent.to_s.should == '/usr'
end
Modified: MacRuby/branches/experimental/spec/frozen/library/pathname/relative_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/pathname/relative_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/pathname/relative_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,19 +3,19 @@
describe "Pathname#relative?" do
- it "should return false for the root directory" do
+ it "returns false for the root directory" do
Pathname.new('/').relative?.should == false
end
- it "should return false for a dir starting with a slash" do
+ it "returns false for a dir starting with a slash" do
Pathname.new('/usr/local/bin').relative?.should == false
end
- it "should return true for a dir not starting with a slash" do
+ it "returns true for a dir not starting with a slash" do
Pathname.new('fish').relative?.should == true
end
- it "should return true for a dir not starting with a slash" do
+ it "returns true for a dir not starting with a slash" do
Pathname.new('fish/dog/cow').relative?.should == true
end
Modified: MacRuby/branches/experimental/spec/frozen/library/pathname/root_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/pathname/root_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/pathname/root_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,23 +3,23 @@
describe "Pathname#root?" do
- it "should return true for root directories" do
+ it "returns true for root directories" do
Pathname.new('/').root?.should == true
end
- it "should return false for empty string" do
+ it "returns false for empty string" do
Pathname.new('').root?.should == false
end
- it "should return false for a top level directory" do
+ it "returns false for a top level directory" do
Pathname.new('/usr').root?.should == false
end
- it "should return false for a top level with .. appended directory" do
+ it "returns false for a top level with .. appended directory" do
Pathname.new('/usr/..').root?.should == false
end
- it "should return false for a directory below top level" do
+ it "returns false for a directory below top level" do
Pathname.new('/usr/local/bin/').root?.should == false
end
Modified: MacRuby/branches/experimental/spec/frozen/library/pathname/sub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/pathname/sub_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/pathname/sub_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,11 +3,11 @@
describe "Pathname#sub" do
- it "should replace the pattern with rest" do
+ it "replaces the pattern with rest" do
Pathname.new('/usr/local/bin/').sub(/local/, 'fish').to_s.should == '/usr/fish/bin/'
end
- it "should return a new object" do
+ it "returns a new object" do
p = Pathname.new('/usr/local/bin/')
p.sub(/local/, 'fish').should_not == p
end
Modified: MacRuby/branches/experimental/spec/frozen/library/set/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/hash_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/set/hash_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,7 +3,7 @@
ruby_version_is "1.8.7" do
describe "Set#hash" do
- it "should be static" do
+ it "is static" do
Set[].hash.should == Set[].hash
Set[1, 2, 3].hash.should == Set[1, 2, 3].hash
Set[:a, "b", ?c].hash.should == Set[?c, "b", :a].hash
Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/add_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -4,6 +4,12 @@
describe "SortedSet#add" do
it_behaves_like :sorted_set_add, :add
+
+ ruby_bug "redmine #118", "1.9" do
+ it "takes only comparable values" do
+ lambda { SortedSet[3, 4].add(SortedSet[5, 6]) }.should raise_error(ArgumentError)
+ end
+ end
end
describe "SortedSet#add?" do
Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/flatten_merge_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,7 +3,7 @@
describe "SortedSet#flatten_merge" do
it "is protected" do
- SortedSet[].protected_methods.should include("flatten_merge")
+ SortedSet.should have_protected_instance_method("flatten_merge")
end
ruby_bug "http://redmine.ruby-lang.org/projects/ruby-18/issues/show?id=117", "1.8.7" do
@@ -22,4 +22,4 @@
lambda { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
end
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/hash_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/hash_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,7 +3,7 @@
ruby_version_is "1.8.7" do
describe "SortedSet#hash" do
- it "should be static" do
+ it "is static" do
SortedSet[].hash.should == SortedSet[].hash
SortedSet[1, 2, 3].hash.should == SortedSet[1, 2, 3].hash
SortedSet["a", "b", "c"].hash.should == SortedSet["c", "b", "a"].hash
Modified: MacRuby/branches/experimental/spec/frozen/library/set/sortedset/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/set/sortedset/initialize_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/set/sortedset/initialize_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,9 +3,9 @@
describe "SortedSet#initialize" do
it "is private" do
- SortedSet[].private_methods.should include("initialize")
+ SortedSet.should have_private_instance_method("initialize")
end
-
+
it "adds all elements of the passed Enumerable to self" do
s = SortedSet.new([1, 2, 3])
s.size.should eql(3)
@@ -13,7 +13,7 @@
s.should include(2)
s.should include(3)
end
-
+
it "preprocesses all elements by a passed block before adding to self" do
s = SortedSet.new([1, 2, 3]) { |x| x * x }
s.size.should eql(3)
@@ -21,4 +21,10 @@
s.should include(4)
s.should include(9)
end
+
+ ruby_bug "redmine #118", "1.9" do
+ it "takes only comparable values" do
+ lambda { SortedSet[3, 4, SortedSet[5, 6]] }.should raise_error(ArgumentError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/recv_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/recv_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/recv_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -19,7 +19,7 @@
data = client.recv(10)
client.close
end
- Thread.pass until t.status == "sleep" or t.status == nil
+ Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
@@ -37,7 +37,7 @@
data = client.recv(10) # in-band data (TCP), doesn't receive the flag.
client.close
end
- Thread.pass until t.status == "sleep" or t.status == nil
+ Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/send_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/send_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/basicsocket/send_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -22,7 +22,7 @@
data = client.recv(5)
client.close
end
- Thread.pass until t.status == "sleep" or t.status == nil
+ Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
@socket.send('hello', 0).should == 5
@@ -40,7 +40,7 @@
data = client.recv(6)
client.close
end
- Thread.pass until t.status == "sleep" or t.status == nil
+ Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
@socket.send('helloU', Socket::MSG_PEEK | Socket::MSG_OOB).should == 6
@@ -57,7 +57,7 @@
data = client.recv(5)
client.close
end
- Thread.pass until t.status == "sleep" or t.status == nil
+ Thread.pass while t.status and t.status != "sleep"
t.status.should_not be_nil
sockaddr = Socket.pack_sockaddr_in(SocketSpecs.port, "127.0.0.1")
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/tcpserver/accept_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/tcpserver/accept_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/tcpserver/accept_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -20,7 +20,7 @@
client << "goodbye"
client.close
end
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
socket = TCPSocket.new('127.0.0.1', SocketSpecs.port)
socket.write('hello')
@@ -33,7 +33,7 @@
it "can be interrupted by Thread#kill" do
t = Thread.new { @server.accept }
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
# kill thread, ensure it dies in a reasonable amount of time
t.kill
@@ -49,7 +49,7 @@
it "can be interrupted by Thread#raise" do
t = Thread.new { @server.accept }
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
# raise in thread, ensure the raise happens
ex = Exception.new
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/tcpsocket/shared/new.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/tcpsocket/shared/new.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/tcpsocket/shared/new.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -19,7 +19,7 @@
server.accept
server.close
end
- Thread.pass until thread.status == 'sleep' or thread.status == nil
+ Thread.pass while thread.status and thread.status != 'sleep'
thread.status.should_not be_nil
lambda {
sock = TCPSocket.new(@hostname, SocketSpecs.port)
@@ -34,7 +34,7 @@
server.accept
server.close
end
- Thread.pass until thread.status == 'sleep' or thread.status == nil
+ Thread.pass while thread.status and thread.status != 'sleep'
thread.status.should_not be_nil
sock = TCPSocket.new('127.0.0.1', SocketSpecs.port)
sock.addr[0].should == "AF_INET"
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_nonblock_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_nonblock_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_nonblock_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1,14 +1,16 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
require File.dirname(__FILE__) + '/../fixtures/classes'
-describe "UNIXSocket#recvfrom" do
+describe "UNIXServer#accept_nonblock" do
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
+
@socket = @server.accept_nonblock
@client.send("foobar", 0)
end
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/unixserver/accept_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -4,11 +4,12 @@
platform_is_not :windows do
describe "UNIXServer#accept" do
before :each do
- FileUtils.rm(SocketSpecs.socket_path, :force => true)
+ @path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
end
- after :all do
- FileUtils.rm(SocketSpecs.socket_path, :force => true)
+ after :each do
+ File.unlink(@path) if File.exists?(@path)
end
it "accepts what is written by the client" do
@@ -28,11 +29,11 @@
end
it "can be interrupted by Thread#kill" do
- server = UNIXServer.new(SocketSpecs.socket_path)
+ server = UNIXServer.new(@path)
t = Thread.new {
server.accept
}
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
# kill thread, ensure it dies in a reasonable amount of time
t.kill
@@ -47,11 +48,11 @@
end
it "can be interrupted by Thread#raise" do
- server = UNIXServer.new(SocketSpecs.socket_path)
+ server = UNIXServer.new(@path)
t = Thread.new {
server.accept
}
- Thread.pass until t.status == "sleep"
+ Thread.pass while t.status and t.status != "sleep"
# raise in thread, ensure the raise happens
ex = Exception.new
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/addr_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/addr_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/addr_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -4,13 +4,15 @@
describe "UNIXSocket#addr" do
platform_is_not :windows do
- before :all do
+ before :each do
@path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
+
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
- after :all do
+ after :each do
@client.close
@server.close
File.unlink(@path) if File.exists?(@path)
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/path_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/path_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/path_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -4,13 +4,15 @@
describe "UNIXSocket#path" do
platform_is_not :windows do
- before :all do
+ before :each do
@path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
+
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
- after :all do
+ after :each do
@client.close
@server.close
File.unlink(@path) if File.exists?(@path)
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/peeraddr_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/peeraddr_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/peeraddr_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -4,13 +4,15 @@
describe "UNIXSocket#peeraddr" do
platform_is_not :windows do
- before :all do
+ before :each do
@path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
+
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
- after :all do
+ after :each do
@client.close
@server.close
File.unlink(@path) if File.exists?(@path)
Modified: MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/recvfrom_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/recvfrom_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/socket/unixsocket/recvfrom_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -6,6 +6,8 @@
platform_is_not :windows do
before :each do
@path = SocketSpecs.socket_path
+ File.unlink(@path) if File.exists?(@path)
+
@server = UNIXServer.open(@path)
@client = UNIXSocket.open(@path)
end
Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/read_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/read_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/read_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -12,8 +12,22 @@
describe "StringIO#read when passed no arguments" do
it_behaves_like :stringio_read_no_arguments, :read
+
+ it "returns an empty string if at EOF" do
+ @io.read.should == "example"
+ @io.read.should == ""
+ end
end
+describe "StringIO#read when passed nil" do
+ it_behaves_like :stringio_read_nil, :read
+
+ it "returns an empty string if at EOF" do
+ @io.read(nil).should == "example"
+ @io.read(nil).should == ""
+ end
+end
+
describe "StringIO#read when self is not readable" do
it_behaves_like :stringio_read_not_readable, :read
end
@@ -32,3 +46,17 @@
@io.read(0).should == ""
end
end
+
+describe "StringIO#read when passed length and a buffer" do
+ before :each do
+ @io = StringIO.new("abcdefghijklmnopqrstuvwxyz")
+ end
+
+ it "reads [length] characters into the buffer" do
+ buf = "foo"
+ result = @io.read(10, buf)
+
+ buf.should == "abcdefghij"
+ result.should equal?(buf)
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/shared/read.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -87,6 +87,24 @@
end
end
+describe :stringio_read_nil, :shared => true do
+ before :each do
+ @io = StringIO.new("example")
+ end
+
+ it "returns the remaining content from the current position" do
+ @io.send(@method, nil).should == "example"
+
+ @io.pos = 4
+ @io.send(@method, nil).should == "ple"
+ end
+
+ it "updates the current position" do
+ @io.send(@method, nil)
+ @io.pos.should eql(7)
+ end
+end
+
describe :stringio_read_not_readable, :shared => true do
it "raises an IOError" do
io = StringIO.new("test", "w")
Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/stringio_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/stringio_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/stringio_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -2,7 +2,7 @@
require "stringio"
describe "StringIO" do
- it "should include the Enumerable module" do
+ it "includes the Enumerable module" do
StringIO.should include(Enumerable)
end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/sysread_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/sysread_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/sysread_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -12,18 +12,35 @@
describe "StringIO#sysread when passed no arguments" do
it_behaves_like :stringio_read_no_arguments, :sysread
+
+ ruby_bug "http://redmine.ruby-lang.org/projects/ruby-18/issues/show?id=156", "1.8.7" do
+ it "returns an empty String if at EOF" do
+ @io.sysread.should == "example"
+ @io.sysread.should == ""
+ end
+ end
end
describe "StringIO#sysread when self is not readable" do
it_behaves_like :stringio_read_not_readable, :sysread
end
+describe "StringIO#sysread when passed nil" do
+ it_behaves_like :stringio_read_nil, :sysread
+ ruby_bug "http://redmine.ruby-lang.org/projects/ruby-18/issues/show?id=156", "1.8.7" do
+ it "returns an empty String if at EOF" do
+ @io.sysread(nil).should == "example"
+ @io.sysread(nil).should == ""
+ end
+ end
+end
+
describe "StringIO#sysread when passed [length]" do
before(:each) do
@io = StringIO.new("example")
end
-
+
it "raises an EOFError when self's position is at the end" do
@io.pos = 7
lambda { @io.sysread(10) }.should raise_error(EOFError)
@@ -34,4 +51,4 @@
@io.sysread(0).should == ""
end
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/ungetc_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -29,9 +29,11 @@
@io.string.should == "1234\000\000\000\000\000\000\000\000\000\000A"
end
- it "does nothing when at the beginning of self" do
- @io.ungetc(65)
- @io.string.should == '1234'
+ ruby_version_is "1.8.6" .. "1.8.6.367" do
+ it "does nothing when at the beginning of self" do
+ @io.ungetc(65)
+ @io.string.should == '1234'
+ end
end
it "tries to convert the passed length to an Integer using #to_int" do
Modified: MacRuby/branches/experimental/spec/frozen/library/timeout/timeout_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/timeout/timeout_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/timeout/timeout_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -10,7 +10,7 @@
}.should raise_error(Timeout::Error)
end
- it "shouldn't wait too long" do
+ it "does not wait too long" do
before_time = Time.now
begin
Timeout::timeout(1) do
@@ -23,7 +23,7 @@
end
end
- it "shouldn't return too quickly" do
+ it "does not return too quickly" do
before_time = Time.now
begin
Timeout::timeout(2) do
@@ -36,7 +36,7 @@
end
end
- it "should return back the last value in the block" do
+ it "returns back the last value in the block" do
Timeout::timeout(1) do
42
end.should == 42
Modified: MacRuby/branches/experimental/spec/frozen/library/zlib/crc_table_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/zlib/crc_table_spec.rb 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/library/zlib/crc_table_spec.rb 2009-05-03 13:28:23 UTC (rev 1523)
@@ -3,9 +3,9 @@
describe "Zlib.crc_table" do
- it "should return the same value as zlib's get_crc_table()" do
+ it "returns the same value as zlib's get_crc_table()" do
Zlib.crc_table.should ==
[0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 181
2370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 36247
41850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918000, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 30206684
71, 3272380065, 1510334235, 755167117]
end
-end
\ No newline at end of file
+end
Modified: MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec
===================================================================
--- MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/ruby.1.9.mspec 2009-05-03 13:28:23 UTC (rev 1523)
@@ -16,6 +16,7 @@
# obsolete libraries
'^library/cgi-lib',
'^library/date2',
+ '^library/enumerator',
'^library/eregex',
'^library/finalize',
'^library/ftools',
Modified: MacRuby/branches/experimental/spec/frozen/upstream
===================================================================
--- MacRuby/branches/experimental/spec/frozen/upstream 2009-05-03 13:26:27 UTC (rev 1522)
+++ MacRuby/branches/experimental/spec/frozen/upstream 2009-05-03 13:28:23 UTC (rev 1523)
@@ -1 +1 @@
-82bfa3dd3455979c5063d942b64a2890cce2a8d3
\ No newline at end of file
+b339f74be925a4b3ea844063920c6a3d4b435f32
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090503/ee587688/attachment-0001.html>
More information about the macruby-changes
mailing list