[macruby-changes] [1513] MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
source_changes at macosforge.org
source_changes at macosforge.org
Sat May 2 07:44:29 PDT 2009
Revision: 1513
http://trac.macosforge.org/projects/ruby/changeset/1513
Author: eloy.de.enige at gmail.com
Date: 2009-05-02 07:44:28 -0700 (Sat, 02 May 2009)
Log Message:
-----------
Break up a big example into smaller more specific ones.
Modified Paths:
--------------
MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
Modified: MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb 2009-05-02 13:56:57 UTC (rev 1512)
+++ MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb 2009-05-02 14:44:28 UTC (rev 1513)
@@ -214,7 +214,7 @@
@o.methodAcceptingTrueBOOL(Object.new).should == 1
end
- it "accepting a Fixnum-compatible object as 'char', 'unsigned char', 'short', 'unsigned short', 'int', 'unsigned int', 'long', 'unsigned long' should receive the converted data, or raise an exception" do
+ it "accepts a Fixnum-compatible object for an argument of types: 'char', 'unsigned char', 'short', 'unsigned short', 'int', 'unsigned int', 'long', 'unsigned long'" do
@o.methodAcceptingChar(42).should == 1
@o.methodAcceptingUnsignedChar(42).should == 1
@o.methodAcceptingShort(42).should == 1
@@ -232,19 +232,9 @@
@o.methodAcceptingUnsignedInt(42.0).should == 1
@o.methodAcceptingLong(42.0).should == 1
@o.methodAcceptingUnsignedLong(42.0).should == 1
+ end
- o2 = Object.new
- def o2.to_i; 42; end
-
- @o.methodAcceptingChar(o2).should == 1
- @o.methodAcceptingUnsignedChar(o2).should == 1
- @o.methodAcceptingShort(o2).should == 1
- @o.methodAcceptingUnsignedShort(o2).should == 1
- @o.methodAcceptingInt(o2).should == 1
- @o.methodAcceptingUnsignedInt(o2).should == 1
- @o.methodAcceptingLong(o2).should == 1
- @o.methodAcceptingUnsignedLong(o2).should == 1
-
+ it "raises a TypeError if an object is given which cannot be coerced to a Fixnum-compatible object for an argument of types: 'char', 'unsigned char', 'short', 'unsigned short', 'int', 'unsigned int', 'long', 'unsigned long'" do
lambda { @o.methodAcceptingChar(nil) }.should raise_error(TypeError)
lambda { @o.methodAcceptingUnsignedChar(nil) }.should raise_error(TypeError)
lambda { @o.methodAcceptingShort(nil) }.should raise_error(TypeError)
@@ -253,7 +243,7 @@
lambda { @o.methodAcceptingUnsignedInt(nil) }.should raise_error(TypeError)
lambda { @o.methodAcceptingLong(nil) }.should raise_error(TypeError)
lambda { @o.methodAcceptingUnsignedLong(nil) }.should raise_error(TypeError)
-
+
lambda { @o.methodAcceptingChar(Object.new) }.should raise_error(TypeError)
lambda { @o.methodAcceptingUnsignedChar(Object.new) }.should raise_error(TypeError)
lambda { @o.methodAcceptingShort(Object.new) }.should raise_error(TypeError)
@@ -264,6 +254,20 @@
lambda { @o.methodAcceptingUnsignedLong(Object.new) }.should raise_error(TypeError)
end
+ it "automatically coerces an object with #to_i for an argument of types: 'char', 'unsigned char', 'short', 'unsigned short', 'int', 'unsigned int', 'long', 'unsigned long'" do
+ o2 = Object.new
+ def o2.to_i; 42; end
+
+ @o.methodAcceptingChar(o2).should == 1
+ @o.methodAcceptingUnsignedChar(o2).should == 1
+ @o.methodAcceptingShort(o2).should == 1
+ @o.methodAcceptingUnsignedShort(o2).should == 1
+ @o.methodAcceptingInt(o2).should == 1
+ @o.methodAcceptingUnsignedInt(o2).should == 1
+ @o.methodAcceptingLong(o2).should == 1
+ @o.methodAcceptingUnsignedLong(o2).should == 1
+ end
+
it "accepting a one-character string as 'char' or 'unsigned char' should receive the first character" do
@o.methodAcceptingChar('*').should == 1
@o.methodAcceptingUnsignedChar('*').should == 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090502/17163991/attachment.html>
More information about the macruby-changes
mailing list