[macruby-changes] [1582] MacRuby/branches/experimental

source_changes at macosforge.org source_changes at macosforge.org
Thu May 21 02:08:46 PDT 2009


Revision: 1582
          http://trac.macosforge.org/projects/ruby/changeset/1582
Author:   eloy.de.enige at gmail.com
Date:     2009-05-21 02:08:45 -0700 (Thu, 21 May 2009)
Log Message:
-----------
Moved MacRuby specs into core and language dirs and added failing tag for a NSNumber example.

Modified Paths:
--------------
    MacRuby/branches/experimental/rakelib/spec.rake

Added Paths:
-----------
    MacRuby/branches/experimental/spec/macruby/core/
    MacRuby/branches/experimental/spec/macruby/core/array_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/cftype_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/constant_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/hash_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/number_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/objc_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/opaque_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/pointer_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/string_spec.rb
    MacRuby/branches/experimental/spec/macruby/core/struct_spec.rb
    MacRuby/branches/experimental/spec/macruby/language/
    MacRuby/branches/experimental/spec/macruby/language/method_spec.rb
    MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb
    MacRuby/branches/experimental/spec/macruby/tags/
    MacRuby/branches/experimental/spec/macruby/tags/macruby/
    MacRuby/branches/experimental/spec/macruby/tags/macruby/core/
    MacRuby/branches/experimental/spec/macruby/tags/macruby/core/number_tags.txt

Removed Paths:
-------------
    MacRuby/branches/experimental/spec/macruby/array_spec.rb
    MacRuby/branches/experimental/spec/macruby/cftype_spec.rb
    MacRuby/branches/experimental/spec/macruby/constant_spec.rb
    MacRuby/branches/experimental/spec/macruby/hash_spec.rb
    MacRuby/branches/experimental/spec/macruby/method_spec.rb
    MacRuby/branches/experimental/spec/macruby/number_spec.rb
    MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
    MacRuby/branches/experimental/spec/macruby/objc_spec.rb
    MacRuby/branches/experimental/spec/macruby/opaque_spec.rb
    MacRuby/branches/experimental/spec/macruby/pointer_spec.rb
    MacRuby/branches/experimental/spec/macruby/string_spec.rb
    MacRuby/branches/experimental/spec/macruby/struct_spec.rb

Modified: MacRuby/branches/experimental/rakelib/spec.rake
===================================================================
--- MacRuby/branches/experimental/rakelib/spec.rake	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/rakelib/spec.rake	2009-05-21 09:08:45 UTC (rev 1582)
@@ -90,7 +90,7 @@
   
   desc "Run all MacRuby-only specs"
   task :macruby do
-    sh "./mspec/bin/mspec run -B #{MACRUBY_MSPEC} ./spec/macruby"
+    sh "./mspec/bin/mspec ci -B #{MACRUBY_MSPEC} ./spec/macruby"
   end
   
   desc "Run language examples that are known to fail"

Deleted: MacRuby/branches/experimental/spec/macruby/array_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/array_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/array_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,71 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "The Array class" do
-  it "is an alias to NSMutableArray" do
-    Array.should == NSMutableArray
-  end
-
-  it "can be subclassed and later instantiated" do
-    k = Class.new(Array)
-    a = k.new
-    a.class.should == k
-    a << 42
-    a[0].should == 42
-  end
-end
-
-=begin
-describe "The NSArray class" do
-  it "can be subclassed and later instantiated" do
-    k = Class.new(NSArray)
-    a = k.new
-    a.class.should == k
-    a.size.should == 0
-    lambda { a << 42 }.should raise_error(RuntimeError)
-  end
-end
-=end
-
-describe "An Array object" do
-  it "is an instance of the Array/NSMutableArray class" do
-    [].class.should == Array
-    [].kind_of?(Array).should == true
-    [].instance_of?(Array).should == true
-  end
-
-  it "is mutable" do
-    a = []
-    a << 42
-    a[0].should == 42
-  end
-
-  it "can have a singleton class" do
-    a = []
-    def a.foo; 42; end
-    a.foo.should == 42
-    a << 42
-    a[0].should == 42
-  end
-end
-
-describe "An NSArray object" do
-  it "is an instance of the NSArray class" do
-    a = NSArray.array
-    a.class.should == NSArray
-  end
-
-  it "is immutable" do
-    a = NSArray.array
-    a.size.should == 0
-    lambda { a << 123 }.should raise_error(RuntimeError)
-  end
-
-=begin
-  it "can have a singleton class" do
-    a = NSArray.array
-    def a.foo; 42; end
-    a.foo.should == 42
-    lambda { a << 123 }.should raise_error(RuntimeError)
-  end
-=end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/cftype_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/cftype_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/cftype_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,34 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-FixtureCompiler.require! "method"
-
-describe "A CoreFoundation type" do
-  it "behaves like a regular Objective-C/Ruby object" do
-    o = CFBundleGetMainBundle()
-    if MACOSX_VERSION <= 10.5
-      o.class.should == NSCFType
-    else
-      # __NSCFType isn't a constant in Ruby so we have to cheat.
-      o.class.should == NSClassFromString('__NSCFType')
-    end
-    o.inspect.class.should == String
-  end
-
-  it "can be passed to a C/Objective-C API" do
-    o = CFBundleGetMainBundle()
-    CFBundleIsExecutableLoaded(o).should == true
-  end
-
-  it "toll-free bridged to an Objective-C type behaves like the Objective-C version" do
-    s = CFStringCreateWithCString(nil, "foo", KCFStringEncodingUTF8)
-    s.class.should == NSString
-    s.should == 'foo'
-    CFRelease(s)
-  end
-
-  it "can be substitued with the toll-free bridged equivalent" do
-    s = CFStringCreateMutableCopy(nil, 0, "foo")
-    s.class.should == NSMutableString
-    s.should == 'foo'
-    CFRelease(s)
-  end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/constant_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/constant_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/constant_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,83 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-FixtureCompiler.require! "constant"
-
-describe "A BridgeSupport constant" do
-  it "of type 'id' is available as an Object in Ruby" do
-    ConstantObject.class.should == NSString
-    ConstantObject.should == 'foo'
-  end
-
-  it "of type 'Class' is available as a Class in Ruby" do
-    ConstantClass.class.should == Class
-    ConstantClass.should == NSObject
-  end
-
-  it "of type 'SEL' is available as a Symbol in Ruby" do
-    ConstantSEL.class.should == Symbol
-    ConstantSEL.should == :'foo:with:with:'
-  end
-
-  it "of type 'char' or 'unsigned char' is available as a Fixnum in Ruby" do
-    ConstantChar.class.should == Fixnum
-    ConstantUnsignedChar.class.should == Fixnum
-    ConstantChar.should == 42
-    ConstantUnsignedChar.should == 42
-  end
-
-  it "of type 'short' or 'unsigned short' is available as a Fixnum in Ruby" do
-    ConstantShort.class.should == Fixnum
-    ConstantUnsignedShort.class.should == Fixnum
-    ConstantShort.should == 42
-    ConstantUnsignedShort.should == 42
-  end
-
-  it "of type 'int' or 'unsigned int' is available as a Fixnum in Ruby" do
-    ConstantInt.class.should == Fixnum
-    ConstantUnsignedInt.class.should == Fixnum
-    ConstantInt.should == 42
-    ConstantUnsignedInt.should == 42
-  end
-
-  it "of type 'long' or 'unsigned long' is available as a Fixnum in Ruby" do
-    ConstantLong.class.should == Fixnum
-    ConstantUnsignedLong.class.should == Fixnum
-    ConstantLong.should == 42
-    ConstantUnsignedLong.should == 42
-  end
-
-  it "of type 'long long' or 'unsigned long long' is available as a Fixnum in Ruby" do
-    ConstantLongLong.class.should == Fixnum
-    ConstantUnsignedLongLong.class.should == Fixnum
-    ConstantLongLong.should == 42
-    ConstantUnsignedLongLong.should == 42
-  end
-
-  it "of type 'float' or 'double' is available as a Float in Ruby" do
-    ConstantFloat.class.should == Float
-    ConstantDouble.class.should == Float
-    ConstantFloat.should.be_close(3.1415, 0.0001)
-    ConstantDouble.should.be_close(3.1415, 0.0001)
-  end
-
-  it "of type 'BOOL' is available as true/false in Ruby" do
-    ConstantYES.class.should == TrueClass
-    ConstantNO.class.should == FalseClass
-    ConstantYES.should == true
-    ConstantNO.should == false
-  end
-
-  it "of type 'NSPoint' is available as an NSPoint boxed instance in Ruby" do
-    ConstantNSPoint.class.should == NSPoint
-    ConstantNSPoint.should == NSPoint.new(1, 2)
-  end
-
-  it "of type 'NSSize' is available as an NSSize boxed instance in Ruby" do
-    ConstantNSSize.class.should == NSSize
-    ConstantNSSize.should == NSSize.new(3, 4)
-  end
-
-  it "of type 'NSRect' is available as an NSRect boxed instance in Ruby" do
-    ConstantNSRect.class.should == NSRect
-    ConstantNSRect.should == NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
-  end
-end

Copied: MacRuby/branches/experimental/spec/macruby/core/array_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/array_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/array_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/array_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,71 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "The Array class" do
+  it "is an alias to NSMutableArray" do
+    Array.should == NSMutableArray
+  end
+
+  it "can be subclassed and later instantiated" do
+    k = Class.new(Array)
+    a = k.new
+    a.class.should == k
+    a << 42
+    a[0].should == 42
+  end
+end
+
+=begin
+describe "The NSArray class" do
+  it "can be subclassed and later instantiated" do
+    k = Class.new(NSArray)
+    a = k.new
+    a.class.should == k
+    a.size.should == 0
+    lambda { a << 42 }.should raise_error(RuntimeError)
+  end
+end
+=end
+
+describe "An Array object" do
+  it "is an instance of the Array/NSMutableArray class" do
+    [].class.should == Array
+    [].kind_of?(Array).should == true
+    [].instance_of?(Array).should == true
+  end
+
+  it "is mutable" do
+    a = []
+    a << 42
+    a[0].should == 42
+  end
+
+  it "can have a singleton class" do
+    a = []
+    def a.foo; 42; end
+    a.foo.should == 42
+    a << 42
+    a[0].should == 42
+  end
+end
+
+describe "An NSArray object" do
+  it "is an instance of the NSArray class" do
+    a = NSArray.array
+    a.class.should == NSArray
+  end
+
+  it "is immutable" do
+    a = NSArray.array
+    a.size.should == 0
+    lambda { a << 123 }.should raise_error(RuntimeError)
+  end
+
+=begin
+  it "can have a singleton class" do
+    a = NSArray.array
+    def a.foo; 42; end
+    a.foo.should == 42
+    lambda { a << 123 }.should raise_error(RuntimeError)
+  end
+=end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/cftype_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/cftype_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/cftype_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/cftype_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,34 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+FixtureCompiler.require! "method"
+
+describe "A CoreFoundation type" do
+  it "behaves like a regular Objective-C/Ruby object" do
+    o = CFBundleGetMainBundle()
+    if MACOSX_VERSION <= 10.5
+      o.class.should == NSCFType
+    else
+      # __NSCFType isn't a constant in Ruby so we have to cheat.
+      o.class.should == NSClassFromString('__NSCFType')
+    end
+    o.inspect.class.should == String
+  end
+
+  it "can be passed to a C/Objective-C API" do
+    o = CFBundleGetMainBundle()
+    CFBundleIsExecutableLoaded(o).should == true
+  end
+
+  it "toll-free bridged to an Objective-C type behaves like the Objective-C version" do
+    s = CFStringCreateWithCString(nil, "foo", KCFStringEncodingUTF8)
+    s.class.should == NSString
+    s.should == 'foo'
+    CFRelease(s)
+  end
+
+  it "can be substitued with the toll-free bridged equivalent" do
+    s = CFStringCreateMutableCopy(nil, 0, "foo")
+    s.class.should == NSMutableString
+    s.should == 'foo'
+    CFRelease(s)
+  end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/constant_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/constant_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/constant_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/constant_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,83 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+FixtureCompiler.require! "constant"
+
+describe "A BridgeSupport constant" do
+  it "of type 'id' is available as an Object in Ruby" do
+    ConstantObject.class.should == NSString
+    ConstantObject.should == 'foo'
+  end
+
+  it "of type 'Class' is available as a Class in Ruby" do
+    ConstantClass.class.should == Class
+    ConstantClass.should == NSObject
+  end
+
+  it "of type 'SEL' is available as a Symbol in Ruby" do
+    ConstantSEL.class.should == Symbol
+    ConstantSEL.should == :'foo:with:with:'
+  end
+
+  it "of type 'char' or 'unsigned char' is available as a Fixnum in Ruby" do
+    ConstantChar.class.should == Fixnum
+    ConstantUnsignedChar.class.should == Fixnum
+    ConstantChar.should == 42
+    ConstantUnsignedChar.should == 42
+  end
+
+  it "of type 'short' or 'unsigned short' is available as a Fixnum in Ruby" do
+    ConstantShort.class.should == Fixnum
+    ConstantUnsignedShort.class.should == Fixnum
+    ConstantShort.should == 42
+    ConstantUnsignedShort.should == 42
+  end
+
+  it "of type 'int' or 'unsigned int' is available as a Fixnum in Ruby" do
+    ConstantInt.class.should == Fixnum
+    ConstantUnsignedInt.class.should == Fixnum
+    ConstantInt.should == 42
+    ConstantUnsignedInt.should == 42
+  end
+
+  it "of type 'long' or 'unsigned long' is available as a Fixnum in Ruby" do
+    ConstantLong.class.should == Fixnum
+    ConstantUnsignedLong.class.should == Fixnum
+    ConstantLong.should == 42
+    ConstantUnsignedLong.should == 42
+  end
+
+  it "of type 'long long' or 'unsigned long long' is available as a Fixnum in Ruby" do
+    ConstantLongLong.class.should == Fixnum
+    ConstantUnsignedLongLong.class.should == Fixnum
+    ConstantLongLong.should == 42
+    ConstantUnsignedLongLong.should == 42
+  end
+
+  it "of type 'float' or 'double' is available as a Float in Ruby" do
+    ConstantFloat.class.should == Float
+    ConstantDouble.class.should == Float
+    ConstantFloat.should.be_close(3.1415, 0.0001)
+    ConstantDouble.should.be_close(3.1415, 0.0001)
+  end
+
+  it "of type 'BOOL' is available as true/false in Ruby" do
+    ConstantYES.class.should == TrueClass
+    ConstantNO.class.should == FalseClass
+    ConstantYES.should == true
+    ConstantNO.should == false
+  end
+
+  it "of type 'NSPoint' is available as an NSPoint boxed instance in Ruby" do
+    ConstantNSPoint.class.should == NSPoint
+    ConstantNSPoint.should == NSPoint.new(1, 2)
+  end
+
+  it "of type 'NSSize' is available as an NSSize boxed instance in Ruby" do
+    ConstantNSSize.class.should == NSSize
+    ConstantNSSize.should == NSSize.new(3, 4)
+  end
+
+  it "of type 'NSRect' is available as an NSRect boxed instance in Ruby" do
+    ConstantNSRect.class.should == NSRect
+    ConstantNSRect.should == NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
+  end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/hash_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/hash_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/hash_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/hash_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,71 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "The Hash class" do
+  it "is an alias to NSMutableDictionary" do
+    Hash.should == NSMutableDictionary
+  end
+
+  it "can be subclassed and later instantiated" do
+    k = Class.new(Hash)
+    a = k.new
+    a.class.should == k
+    a[42] = 123
+    a[42].should == 123
+  end
+end
+
+=begin
+describe "The NSDictionary class" do
+  it "can be subclassed and later instantiated" do
+    k = Class.new(NSDictionary)
+    a = k.new
+    a.class.should == k
+    a.size.should == 0
+    lambda { a[42] = 123 }.should raise_error(RuntimeError)
+  end
+end
+=end
+
+describe "An Hash object" do
+  it "is an instance of the Hash/NSMutableDictionary class" do
+    {}.class.should == Hash
+    {}.kind_of?(Hash).should == true
+    {}.instance_of?(Hash).should == true
+  end
+
+  it "is mutable" do
+    a = {}
+    a[42] = 123
+    a[42].should == 123
+  end
+
+  it "can have a singleton class" do
+    a = {}
+    def a.foo; 42; end
+    a.foo.should == 42
+    a[42] = 123
+    a[42].should == 123
+  end
+end
+
+describe "An NSDictionary object" do
+  it "is an instance of the NSDictionary class" do
+    a = NSDictionary.dictionary
+    a.class.should == NSDictionary
+  end
+
+  it "is immutable" do
+    a = NSDictionary.dictionary
+    a.size.should == 0
+    lambda { a[42] = 123 }.should raise_error(RuntimeError)
+  end
+
+=begin
+  it "can have a singleton class" do
+    a = NSDictionary.array
+    def a.foo; 42; end
+    a.foo.should == 42
+    lambda { a[42] = 123 }.should raise_error(RuntimeError)
+  end
+=end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/number_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/number_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/number_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/number_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,12 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "An NSNumber boolean object" do
+  it "can be compared against a true/false Ruby type" do
+    true.should == NSNumber.numberWithBool(true)
+    true.should != NSNumber.numberWithBool(false)
+    false.should == NSNumber.numberWithBool(false)
+    false.should != NSNumber.numberWithBool(true)
+  end
+end
+
+# TODO cover the Numeric interface on top of NSNumber

Copied: MacRuby/branches/experimental/spec/macruby/core/objc_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/objc_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/objc_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/objc_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,46 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+# TODO: the MacRuby class should also be tested from Objective-C.
+#FixtureCompiler.require! "objc"
+
+describe "-[MacRuby sharedRuntime]" do
+  before :each do
+    @r = MacRuby.sharedRuntime
+  end
+
+  it "initializes and return a singleton instance representing the runtime" do
+    @r.class.should == MacRuby
+    @r.should == MacRuby.sharedRuntime
+  end
+
+  it "can evaluate a given Ruby expression" do
+    o = @r.evaluateString('1+2')
+    o.class.should == Fixnum
+    o.should == 3
+
+    lambda { @r.evaluateString('1+') }.should raise_error(SyntaxError)
+    lambda { @r.evaluateString('foo') }.should raise_error(NameError)
+  end
+
+  it "can evaluate a given Ruby file using a path or an URL" do
+    p1 = File.join(FIXTURES, 'test_objc1.rb')
+    p2 = File.join(FIXTURES, 'test_objc2.rb')
+
+    o = @r.evaluateFileAtPath(p1)
+    o.class.should == Fixnum
+    o.should == 3
+
+    o = @r.evaluateFileAtURL(NSURL.fileURLWithPath(p1))
+    o.class.should == Fixnum
+    o.should == 3
+
+    lambda { @r.evaluateFileAtPath(p2) }.should raise_error(NameError)
+    lambda { @r.evaluateFileAtURL(NSURL.fileURLWithPath(p2)) }.should raise_error(NameError)
+
+    # TODO: add tests that should raise_error for the following cases:
+    # - given path is nil
+    # - given path does not exist
+    # - given URL is nil
+    # - given file:// URL does not exist
+    # - given URL is not file://
+  end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/opaque_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/opaque_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/opaque_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/opaque_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,32 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "A BridgeSupport opaque type" do
+  it "is an instance of Boxed" do
+    NSZone.superclass.should == Boxed
+  end
+
+  it "cannot be created with #new" do
+    lambda { NSZone.new }.should raise_error(RuntimeError)
+  end
+
+  it "can be created from an Objective-C API, and passed back to Objective-C" do
+    z = 123.zone
+    z.class.should == NSZone
+    lambda { Object.allocWithZone(z).init }.should_not raise_error
+    lambda { Object.allocWithZone(nil).init }.should_not raise_error
+    lambda { Object.allocWithZone(123).init }.should raise_error(TypeError)
+    lambda { Object.allocWithZone(NSPoint.new).init }.should raise_error(TypeError)
+  end
+
+  it "can be compared to an exact same instance using #==" do
+    123.zone.should == 456.zone
+  end
+
+  it "returns true when the #opaque? class method is called" do
+    NSZone.opaque?.should == true
+  end 
+
+  it "returns its Objective-C encoding type when then #type class method is called" do
+    NSZone.type.should == '^{_NSZone=}'
+  end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/pointer_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/pointer_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/pointer_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/pointer_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,114 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "A Pointer object, when initializing" do
+  before :all do
+    @types = {
+      :object     => '@',
+      :char       => 'c',
+      :uchar      => 'C',
+      :short      => 's',
+      :ushort     => 'S',
+      :int        => 'i',
+      :uint       => 'I',
+      :long       => 'l',
+      :ulong      => 'L',
+      :long_long  => 'q',
+      :ulong_long => 'Q',
+      :float      => 'f',
+      :double     => 'd'
+    }
+  end
+
+  it "accepts a valid Objective-C type string" do
+    @types.values.each do |type|
+      lambda { @pointer = Pointer.new(type) }.should_not raise_error
+      @pointer.type.should == type
+    end
+  end
+
+  it "accepts a Symbol argument which responds to a valid Objective-C type" do
+    @types.each do |symbol, type|
+      lambda { @pointer = Pointer.new(symbol) }.should_not raise_error
+      @pointer.type.should == type
+    end
+  end
+
+  it "raises an ArgumentError when no argument is given" do
+    lambda { Pointer.new }.should raise_error(ArgumentError)
+  end
+
+  it "raises a TypeError when a incompatible object is given" do
+    lambda { Pointer.new(nil) }.should raise_error(TypeError)
+    lambda { Pointer.new(123) }.should raise_error(TypeError)
+    lambda { Pointer.new('x') }.should raise_error(TypeError)
+  end
+
+  it "accepts the type returned by NSRect" do
+    Pointer.new(NSRect.type).type.should == NSRect.type
+  end
+end
+
+describe "Pointer, through #[] and #[]=" do
+  integer_types = %w{ char uchar short ushort int uint long ulong long_long ulong_long }
+  float_types   = %w{ float double }
+
+  structs       = [NSPoint.new(1, 2), NSSize.new(3, 4), NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))]
+  struct_types  = structs.map { |x| x.class.type }
+  structs       = structs.zip(struct_types)
+
+  it "can assign and retrieve any object with type `object'" do
+    pointer = Pointer.new('object')
+    [Object.new, 123].each do |object|
+      pointer[0] = object
+      pointer[0].should == object
+      pointer[0].should be_kind_of(object.class)
+    end
+  end
+
+  integer_types.each do |type|
+    it "can assign and retrieve Fixnum compatible objects for type `#{type}'" do
+      pointer = Pointer.new(type)
+
+      coercable_object = Object.new
+      def coercable_object.to_i; 42; end
+
+      [42, coercable_object].each do |object|
+        pointer[0] = object
+        pointer[0].should == 42
+        pointer[0].should be_kind_of(Fixnum)
+      end
+    end
+  end
+  
+  float_types.each do |type|
+    it "can assign and retrieve Float compatible objects for type `#{type}'" do
+      pointer = Pointer.new(type)
+
+      coercable_object = Object.new
+      def coercable_object.to_f; 42.0; end
+
+      [42, coercable_object].each do |object|
+        pointer[0] = object
+        pointer[0].should == 42.0
+        pointer[0].should be_kind_of(Float)
+      end
+    end
+  end
+
+  structs.each do |struct, type|
+    it "can assign and retrieve #{struct.class.name} objects for type `#{type}'" do
+      pointer = Pointer.new(type)
+
+      pointer[0] = struct
+      pointer[0].should == struct
+      pointer[0].should be_kind_of(struct.class)
+    end
+  end
+
+  (integer_types + float_types + struct_types).each do |type|
+    it "raises a TypeError when assigned an object not of type `#{type}'" do
+      pointer = Pointer.new(type)
+      lambda { pointer[0] = Object.new }.should raise_error(TypeError)
+    end
+  end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/string_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/string_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/string_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/string_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,71 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "The String class" do
+  it "is an alias to NSMutableString" do
+    String.should == NSMutableString
+  end
+
+  it "can be subclassed and later instantiated" do
+    k = Class.new(String)
+    a = k.new
+    a.class.should == k
+    a << 'foo'
+    a.should == 'foo'
+  end
+end
+
+=begin
+describe "The NSString class" do
+  it "can be subclassed and later instantiated" do
+    k = Class.new(NSString)
+    a = k.new
+    a.class.should == k
+    a.size.should == 0
+    lambda { a << 'foo' }.should raise_error(RuntimeError)
+  end
+end
+=end
+
+describe "An String object" do
+  it "is an instance of the String/NSMutableString class" do
+    ''.class.should == String
+    ''.kind_of?(String).should == true
+    ''.instance_of?(String).should == true
+  end
+
+  it "is mutable" do
+    a = ''
+    a << 'foo'
+    a.should == 'foo'
+  end
+
+  it "can have a singleton class" do
+    a = ''
+    def a.foo; 42; end
+    a.foo.should == 42
+    a << 'foo'
+    a.should == 'foo'
+  end
+end
+
+describe "An NSString object" do
+  it "is an instance of the NSString class" do
+    a = NSString.string
+    a.class.should == NSString
+  end
+
+  it "is immutable" do
+    a = NSString.string
+    a.size.should == 0
+    lambda { a << 'foo' }.should raise_error(RuntimeError)
+  end
+
+=begin
+  it "can have a singleton class" do
+    a = NSString.string
+    def a.foo; 42; end
+    a.foo.should == 42
+    lambda { a << 'foo' }.should raise_error(RuntimeError)
+  end
+=end
+end

Copied: MacRuby/branches/experimental/spec/macruby/core/struct_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/struct_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/core/struct_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/core/struct_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,215 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "A BridgeSupport structure" do
+  it "is an instance of Boxed" do
+    NSPoint.superclass.should == Boxed
+    NSSize.superclass.should == Boxed
+    NSRect.superclass.should == Boxed
+    NSRange.superclass.should == Boxed
+  end
+
+  it "can be created with null values using the #new method with no argument" do
+    o = NSPoint.new
+    o.x.class.should == Float
+    o.y.class.should == Float
+    o.x.should == 0.0
+    o.y.should == 0.0
+
+    o = NSRect.new
+    o.origin.class.should == NSPoint
+    o.origin.x.class.should == Float
+    o.origin.y.class.should == Float
+    o.origin.x.should == 0.0
+    o.origin.y.should == 0.0
+    o.size.class.should == NSSize
+    o.size.width.class.should == Float
+    o.size.height.class.should == Float
+    o.size.width.should == 0.0
+    o.size.height.should == 0.0
+  end
+
+  it "can be created with given values using the #new method with arguments" do
+    o = NSPoint.new(1.0, 2.0)
+    o.y.class.should == Float
+    o.x.class.should == Float
+    o.x.should == 1.0
+    o.y.should == 2.0
+
+    o = NSPoint.new(1, 2)
+    o.x.class.should == Float
+    o.y.class.should == Float
+    o.x.should == 1.0
+    o.y.should == 2.0
+
+    fix1 = Object.new; def fix1.to_f; 1.0; end
+    fix2 = Object.new; def fix2.to_f; 2.0; end
+
+    o = NSPoint.new(fix1, fix2)
+    o.x.class.should == Float
+    o.y.class.should == Float
+    o.x.should == 1.0
+    o.y.should == 2.0
+
+    lambda { NSPoint.new(1) }.should raise_error(ArgumentError) 
+    lambda { NSPoint.new(1, 2, 3) }.should raise_error(ArgumentError)
+    lambda { NSPoint.new(Object.new, 42) }.should raise_error(TypeError)
+    lambda { NSPoint.new(nil, nil) }.should raise_error(TypeError)
+
+    o = NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
+    o.origin.class.should == NSPoint
+    o.origin.x.class.should == Float
+    o.origin.y.class.should == Float
+    o.origin.x == 1.0
+    o.origin.y == 2.0
+    o.size.class.should == NSSize
+    o.size.width.class.should == Float
+    o.size.height.class.should == Float
+    o.size.width == 3.0
+    o.size.height == 4.0
+
+    lambda { NSRect.new(1) }.should raise_error(ArgumentError)
+    lambda { NSRect.new(1, 2) }.should raise_error(TypeError)
+    lambda { NSRect.new(1, 2, 3) }.should raise_error(ArgumentError)
+    lambda { NSRect.new(1, 2, 3, 4) }.should raise_error(ArgumentError)
+    lambda { NSRect.new(NSSize.new, NSPoint.new) }.should raise_error(TypeError)
+    lambda { NSRect.new(nil, nil) }.should raise_error(TypeError)
+  end
+
+  it "has accessors for every field" do
+    p = NSPoint.new
+    p.x = 1
+    p.y = 2
+    p.x.class.should == Float
+    p.y.class.should == Float
+    p.x.should == 1.0
+    p.y.should == 2.0
+
+    s = NSSize.new
+    s.width = 3
+    s.height = 4
+    s.width.class.should == Float
+    s.height.class.should == Float
+    s.width.should == 3.0
+    s.height.should == 4.0
+
+    r = NSRect.new
+    r.origin = p
+    r.size = s
+    r.origin.class.should == NSPoint
+    r.size.class.should == NSSize
+
+    lambda { r.origin = nil }.should raise_error(TypeError)
+    lambda { r.origin = Object.new }.should raise_error(TypeError)
+
+    r.origin = [123, 456]
+    r.size = [789, 100]
+    
+    r.origin.x.class.should == Float
+    r.origin.y.class.should == Float
+    r.size.width.class.should == Float
+    r.size.height.class.should == Float
+    r.origin.x.should == 123.0
+    r.origin.y.should == 456.0
+    r.size.width.should == 789.0
+    r.size.height.should == 100.0
+  end
+
+  it "can be compared to another similar object using #==" do
+    p1 = NSPoint.new(1, 2)
+    p2 = NSPoint.new(3, 4)
+    p1.should_not == p2
+
+    p2.x = 1
+    p2.y = 2
+    p1.should == p2
+
+    r1 = NSRect.new
+    r2 = NSRect.new
+    r1.should == r2
+
+    r1.origin = NSPoint.new(1, 2)
+    r1.size = NSSize.new(3, 4)
+    r2.origin = NSPoint.new(1, 2)
+    r2.size = NSSize.new(3, 42)
+    r1.should_not == r2
+
+    r2.size.height = 4
+    r1.should == r2
+
+    NSPoint.new.should_not == nil
+    NSPoint.new.should_not == 123
+    NSPoint.new.should_not == [0, 0]
+    NSPoint.new.should_not == [0.0, 0.0]
+    NSPoint.new.should_not == NSSize.new
+  end
+
+  it "has a nice #inspect message that lists the fields" do
+    p = NSPoint.new
+    p.inspect.should == "#<CGPoint x=0.0 y=0.0>"
+    p.x = 1
+    p.y = 2
+    p.inspect.should == "#<CGPoint x=1.0 y=2.0>"
+
+    s = NSSize.new(3, 4)
+    s.inspect.should == "#<CGSize width=3.0 height=4.0>"
+
+    r = NSRect.new
+    r.inspect.should == "#<CGRect origin=#<CGPoint x=0.0 y=0.0> size=#<CGSize width=0.0 height=0.0>>"
+    r.origin = p
+    r.inspect.should == "#<CGRect origin=#<CGPoint x=1.0 y=2.0> size=#<CGSize width=0.0 height=0.0>>"
+    r.size = s
+    r.inspect.should == "#<CGRect origin=#<CGPoint x=1.0 y=2.0> size=#<CGSize width=3.0 height=4.0>>"
+  end
+
+  it "can be duplicated using #dup or #clone" do
+    p = NSPoint.new(1, 2)
+    p.should == p.dup
+    p.should == p.clone
+
+    p2 = p.dup
+    p2.x = 42
+    p2.should_not == p
+
+    r = NSRect.new
+    r.origin.x = 1
+    r.origin.y = 2
+    r2 = r.dup
+    r.size.width = 3.0
+    r.size.height = 4.0
+    r2.size = NSSize.new(3, 4)
+    r.should == r2
+  end
+
+  it "returns the list of fields when the #fields class method is called" do
+    NSPoint.fields.should == [:x, :y]
+    NSSize.fields.should == [:width, :height]
+    NSRect.fields.should == [:origin, :size]
+  end
+
+  it "returns false when the #opaque? class method is called" do
+    NSPoint.opaque?.should == false
+    NSSize.opaque?.should == false
+    NSRect.opaque?.should == false
+  end
+
+  it "returns its Objective-C encoding type when then #type class method is called" do
+    if RUBY_ARCH == 'x86_64'
+      NSPoint.type.should == '{CGPoint=dd}'
+      NSSize.type.should == '{CGSize=dd}'
+      NSRect.type.should == '{CGRect={CGPoint=dd}{CGSize=dd}}'
+    else
+      NSPoint.type.should == '{_NSPoint=ff}'
+      NSSize.type.should == '{_NSSize=ff}'
+      NSRect.type.should == '{_NSRect={_NSPoint=ff}{_NSSize=ff}}'
+    end
+  end
+
+  it "defined after a structure which has the same type is an alias to the other structure class" do
+    NSPoint.should == CGPoint
+    NSSize.should == CGSize
+    NSRect.should == CGRect
+    NSPoint.object_id.should == CGPoint.object_id
+    NSSize.object_id.should == CGSize.object_id
+    NSRect.object_id.should == CGRect.object_id
+  end
+end

Deleted: MacRuby/branches/experimental/spec/macruby/hash_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/hash_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/hash_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,71 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "The Hash class" do
-  it "is an alias to NSMutableDictionary" do
-    Hash.should == NSMutableDictionary
-  end
-
-  it "can be subclassed and later instantiated" do
-    k = Class.new(Hash)
-    a = k.new
-    a.class.should == k
-    a[42] = 123
-    a[42].should == 123
-  end
-end
-
-=begin
-describe "The NSDictionary class" do
-  it "can be subclassed and later instantiated" do
-    k = Class.new(NSDictionary)
-    a = k.new
-    a.class.should == k
-    a.size.should == 0
-    lambda { a[42] = 123 }.should raise_error(RuntimeError)
-  end
-end
-=end
-
-describe "An Hash object" do
-  it "is an instance of the Hash/NSMutableDictionary class" do
-    {}.class.should == Hash
-    {}.kind_of?(Hash).should == true
-    {}.instance_of?(Hash).should == true
-  end
-
-  it "is mutable" do
-    a = {}
-    a[42] = 123
-    a[42].should == 123
-  end
-
-  it "can have a singleton class" do
-    a = {}
-    def a.foo; 42; end
-    a.foo.should == 42
-    a[42] = 123
-    a[42].should == 123
-  end
-end
-
-describe "An NSDictionary object" do
-  it "is an instance of the NSDictionary class" do
-    a = NSDictionary.dictionary
-    a.class.should == NSDictionary
-  end
-
-  it "is immutable" do
-    a = NSDictionary.dictionary
-    a.size.should == 0
-    lambda { a[42] = 123 }.should raise_error(RuntimeError)
-  end
-
-=begin
-  it "can have a singleton class" do
-    a = NSDictionary.array
-    def a.foo; 42; end
-    a.foo.should == 42
-    lambda { a[42] = 123 }.should raise_error(RuntimeError)
-  end
-=end
-end

Copied: MacRuby/branches/experimental/spec/macruby/language/method_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/method_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/language/method_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/language/method_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,83 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+
+describe "A pure MacRuby method" do
+  before :each do
+    @o = Object.new
+  end
+
+  it "uses argument-names + colon + variable syntax to form the method name" do
+    def @o.doSomething(x, withObject:y); x + y; end
+
+    @o.should have_method(:'doSomething:withObject:')
+    @o.should_not have_method(:'doSomething')
+  end
+
+  it "can have multiple arguments with the same name" do
+    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
+
+    @o.should have_method(:'doSomething:withObject:withObject:')
+    @o.should_not have_method(:'doSomething')
+  end
+
+  it "can coexist with other selectors whose first named argument(s) is/are the same" do
+    def @o.foo(x); x; end
+    def @o.foo(x, withObject:y); x + y; end
+    def @o.foo(x, withObject:y, withObject:z); x + y + z; end
+
+    @o.should have_method(:'foo')
+    @o.should have_method(:'foo:withObject:')
+    @o.should have_method(:'foo:withObject:withObject:')
+  end
+
+  it "must start with a regular argument variable followed by argument-names" do
+    lambda { eval("def foo(x:y); end") }.should raise_error(SyntaxError)
+    lambda { eval("def foo(x, y, with:z); end") }.should raise_error(SyntaxError)
+    lambda { eval("def foo(x, with:y, z); end") }.should raise_error(SyntaxError)
+  end
+
+  it "can be called using argument-names + colon + variable syntax" do
+    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
+    @o.doSomething(30, withObject:10, withObject:2).should == 42
+  end
+
+  it "can be called using argument-name-as-symbols + => + variable syntax" do
+    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
+    @o.doSomething(30, :withObject => 10, :withObject => 2).should == 42
+  end
+
+  it "can be called mixing both syntaxes" do
+    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
+    @o.doSomething(30, withObject:10, :withObject => 2).should == 42
+  end
+
+  it "can be called using #send" do
+    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
+    @o.send(:'doSomething:withObject:withObject:', 30, 10, 2).should == 42
+  end
+
+  it "can be called using -[NSObject performSelector:]" do
+    def @o.doSomething; 42; end
+    @o.performSelector(:'doSomething').should == 42
+  end
+
+  it "can be called using -[NSObject performSelector:withObject:]" do
+    def @o.doSomething(x); x; end
+    @o.performSelector(:'doSomething:', withObject:42).should == 42
+  end
+
+  it "can be called using -[NSObject performSelector:withObject:withObject:]" do
+    def @o.doSomething(x, withObject:y); x + y; end
+    @o.performSelector(:'doSomething:withObject:',
+                       withObject:40, withObject:2).should == 42
+  end
+
+  it "cannot be called with #foo=, even if it matches the Objective-C #setFoo pattern" do
+    def @o.setFoo(x); end
+    @o.should_not have_method(:'foo=')
+  end
+
+  it "cannot be called with #foo?, even if it matches the Objective-C #isFoo pattern" do
+    def @o.isFoo; end
+    @o.should_not have_method(:'foo?')
+  end
+end

Copied: MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb (from rev 1581, MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb)
===================================================================
--- MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/language/objc_method_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1,519 @@
+require File.dirname(__FILE__) + "/../spec_helper"
+FixtureCompiler.require! "method"
+
+require File.join(FIXTURES, 'method')
+
+describe "A pure Objective-C method" do
+  before :each do
+    @o = TestMethod.new
+  end
+
+  it "can be called with #foo= if it matches the #setFoo pattern" do
+    @o.should respond_to(:'setFoo')
+    @o.should respond_to(:'foo=')
+
+    @o.setFoo(123)
+    @o.foo.should == 123
+    @o.foo = 456
+    @o.foo.should == 456
+  end
+
+  it "can be called with #foo? if it matches the #isFoo pattern" do
+    @o.should respond_to(:'isFoo')
+    @o.should respond_to(:'foo?')
+
+    @o.foo?.should equal(@o.isFoo)
+  end
+
+  it "is only exposed in #methods if the second argument is true" do
+    @o.methods.should_not include(:'performSelector')
+    @o.methods(true).should_not include(:'performSelector')
+    @o.methods(true, true).should include(:'performSelector')
+  end
+
+  it "can be called on an immediate object" do
+    123.self.should == 123
+    true.self.should == true
+    false.self.should == false
+    nil.self.should == nil
+  end
+
+  it "returning void returns nil in Ruby" do
+    @o.methodReturningVoid.should == nil
+  end
+
+  it "returning nil returns nil in Ruby" do
+    @o.methodReturningNil.should == nil
+  end
+
+  it "returning self returns the same receiver object" do
+    @o.methodReturningSelf.should == @o
+    @o.methodReturningSelf.object_id == @o.object_id
+  end
+
+  it "returning kCFBooleanTrue returns true in Ruby" do
+    @o.methodReturningCFTrue.should == true
+    @o.methodReturningCFTrue.class.should == TrueClass
+  end
+
+  it "returning kCFBooleanFalse returns false in Ruby" do
+    @o.methodReturningCFFalse.should == false
+    @o.methodReturningCFFalse.class.should == FalseClass
+  end
+
+  it "returning kCFNull returns nil in Ruby" do
+    @o.methodReturningCFNull.should == nil
+    @o.methodReturningCFNull.class.should == NilClass
+  end
+
+  it "returning YES returns true in Ruby" do
+    @o.methodReturningYES.should == true
+  end
+
+  it "returning NO returns true in Ruby" do
+    @o.methodReturningNO.should == false
+  end
+
+  it "returning 'char' or 'unsigned char' returns a Fixnum in Ruby" do
+    @o.methodReturningChar.should == 42
+    @o.methodReturningChar2.should == -42
+    @o.methodReturningUnsignedChar.should == 42
+  end
+ 
+  it "returning 'short' or 'unsigned short' returns a Fixnum in Ruby" do
+    @o.methodReturningShort.should == 42
+    @o.methodReturningShort2.should == -42
+    @o.methodReturningUnsignedShort.should == 42
+  end
+
+  it "returning 'int' or 'unsigned int' returns a Fixnum in Ruby" do
+    @o.methodReturningInt.should == 42
+    @o.methodReturningInt2.should == -42
+    @o.methodReturningUnsignedInt.should == 42
+  end
+
+  it "returning 'long' or 'unsigned long' returns a Fixnum if possible in Ruby" do
+    @o.methodReturningLong.should == 42
+    @o.methodReturningLong2.should == -42
+    @o.methodReturningUnsignedLong.should == 42
+  end
+
+  it "returning 'long' or 'unsigned long' returns a Bignum if it cannot fix in a Fixnum in Ruby" do
+    @o.methodReturningLong3.should ==
+      (RUBY_ARCH == 'x86_64' ? 4611686018427387904 : 1073741824)
+    @o.methodReturningLong3.class.should == Bignum
+    @o.methodReturningLong4.should ==
+      (RUBY_ARCH == 'x86_64' ? -4611686018427387905 : -1073741825)
+    @o.methodReturningLong4.class.should == Bignum
+    @o.methodReturningUnsignedLong2.should ==
+      (RUBY_ARCH == 'x86_64' ? 4611686018427387904 : 1073741824)
+    @o.methodReturningUnsignedLong2.class.should == Bignum
+  end
+
+  it "returning 'float' returns a Float in Ruby" do
+    @o.methodReturningFloat.should be_close(3.1415, 0.0001)
+    @o.methodReturningFloat.class.should == Float
+  end
+
+  it "returning 'double' returns a Float in Ruby" do
+    @o.methodReturningDouble.should be_close(3.1415, 0.0001)
+    @o.methodReturningDouble.class.should == Float
+  end
+
+  it "returning 'SEL' returns a Symbol or nil in Ruby" do
+    @o.methodReturningSEL.class.should == Symbol
+    @o.methodReturningSEL.should == :'foo:with:with:'
+    @o.methodReturningSEL2.class.should == NilClass
+    @o.methodReturningSEL2.should == nil
+  end
+
+  it "returning 'char *' returns a String or nil in Ruby" do
+    @o.methodReturningCharPtr.class.should == String
+    @o.methodReturningCharPtr.should == 'foo'
+    @o.methodReturningCharPtr2.class.should == NilClass
+    @o.methodReturningCharPtr2.should == nil
+  end
+
+  it "returning 'NSPoint' returns an NSPoint boxed object in Ruby" do
+    b = @o.methodReturningNSPoint
+    b.class.should == NSPoint
+    b.x.class.should == Float
+    b.x.should == 1.0
+    b.y.class.should == Float
+    b.y.should == 2.0
+  end
+
+  it "returning 'NSSize' returns an NSSize boxed object in Ruby" do
+    b = @o.methodReturningNSSize
+    b.class.should == NSSize
+    b.width.class.should == Float
+    b.width.should == 3.0
+    b.height.class.should == Float
+    b.height.should == 4.0
+  end
+
+  it "returning 'NSRect' returns an NSRect boxed object in Ruby" do
+    b = @o.methodReturningNSRect
+    b.class.should == NSRect
+    b.origin.class.should == NSPoint
+    b.origin.x.should == 1.0
+    b.origin.y.should == 2.0
+    b.size.class.should == NSSize
+    b.size.width.should == 3.0
+    b.size.height.should == 4.0
+  end
+
+  it "returning 'NSRange' returns an NSRange boxed object in Ruby" do
+    b = @o.methodReturningNSRange
+    b.class.should == NSRange
+    b.location.class.should == Fixnum
+    b.location.should == 0
+    b.length.class.should == Fixnum
+    b.length.should == 42
+  end
+
+  it "accepting the receiver as 'id' should receive the exact same object" do
+    @o.methodAcceptingSelf(@o).should == 1
+  end
+
+  it "accepting the receiver's class as 'id' should receive the exact same object" do
+    @o.methodAcceptingSelfClass(@o.class).should == 1
+  end
+
+  it "accepting 'nil' as 'id' should receive Objective-C's nil" do
+    @o.methodAcceptingNil(nil).should == 1
+  end
+
+  it "accepting 'true' as 'id; should receive CF's kCFBooleanTrue" do
+    @o.methodAcceptingTrue(true).should == 1
+  end
+
+  it "accepting 'false' as 'id' should receive CF's kCFBooleanFalse" do
+    @o.methodAcceptingFalse(false).should == 1
+  end
+
+  it "accepting a Fixnum as 'id' should receive a Fixnum boxed object" do
+    @o.methodAcceptingFixnum(42).should == 1
+  end
+
+  it "accepting nil or false as 'BOOL' should receive NO, any other object should receive YES" do
+    @o.methodAcceptingFalseBOOL(nil).should == 1
+    @o.methodAcceptingFalseBOOL(false).should == 1
+
+    @o.methodAcceptingTrueBOOL(true).should == 1
+    @o.methodAcceptingTrueBOOL(0).should == 1
+    @o.methodAcceptingTrueBOOL(123).should == 1
+    @o.methodAcceptingTrueBOOL('foo').should == 1
+    @o.methodAcceptingTrueBOOL(Object.new).should == 1
+  end
+
+  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
+    @o.methodAcceptingUnsignedShort(42).should == 1
+    @o.methodAcceptingInt(42).should == 1
+    @o.methodAcceptingUnsignedInt(42).should == 1
+    @o.methodAcceptingLong(42).should == 1
+    @o.methodAcceptingUnsignedLong(42).should == 1
+
+    @o.methodAcceptingChar(42.0).should == 1
+    @o.methodAcceptingUnsignedChar(42.0).should == 1
+    @o.methodAcceptingShort(42.0).should == 1
+    @o.methodAcceptingUnsignedShort(42.0).should == 1
+    @o.methodAcceptingInt(42.0).should == 1
+    @o.methodAcceptingUnsignedInt(42.0).should == 1
+    @o.methodAcceptingLong(42.0).should == 1
+    @o.methodAcceptingUnsignedLong(42.0).should == 1
+  end
+
+  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)
+    lambda { @o.methodAcceptingUnsignedShort(nil) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingInt(nil) }.should raise_error(TypeError)
+    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)
+    lambda { @o.methodAcceptingUnsignedShort(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingInt(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingUnsignedInt(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingLong(Object.new) }.should raise_error(TypeError)
+    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
+  end
+
+  it "accepting a String, Symbol or nil as 'SEL' should receive the appropriate selector" do
+    @o.methodAcceptingSEL(:'foo:with:with:').should == 1
+    @o.methodAcceptingSEL('foo:with:with:').should == 1
+    @o.methodAcceptingSEL2(nil).should == 1
+
+    lambda { @o.methodAcceptingSEL(123) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingSEL(Object.new) }.should raise_error(TypeError)
+  end
+
+  it "accepting a Float-compatible object as 'float' or 'double' should receive the appropriate data" do
+    @o.methodAcceptingFloat(3.1415).should == 1 
+    @o.methodAcceptingDouble(3.1415).should == 1
+
+    o2 = Object.new
+    def o2.to_f; 3.1415; end
+
+    @o.methodAcceptingFloat(o2).should == 1 
+    @o.methodAcceptingDouble(o2).should == 1
+
+    lambda { @o.methodAcceptingFloat(nil) }.should raise_error(TypeError) 
+    lambda { @o.methodAcceptingDouble(nil) }.should raise_error(TypeError) 
+    lambda { @o.methodAcceptingFloat(Object.new) }.should raise_error(TypeError) 
+    lambda { @o.methodAcceptingDouble(Object.new) }.should raise_error(TypeError) 
+  end
+
+  it "accepting a String-compatible object as 'char *' should receive the appropriate data" do
+    @o.methodAcceptingCharPtr('foo').should == 1
+
+    o2 = Object.new
+    def o2.to_str; 'foo' end
+
+    @o.methodAcceptingCharPtr(o2).should == 1
+
+    lambda { @o.methodAcceptingCharPtr(123) }.should raise_error(TypeError) 
+    lambda { @o.methodAcceptingCharPtr([]) }.should raise_error(TypeError) 
+    lambda { @o.methodAcceptingCharPtr(Object.new) }.should raise_error(TypeError) 
+
+    @o.methodAcceptingCharPtr2(nil).should == 1
+  end
+
+  it "accepting an NSPoint, NSSize, NSRange or NSRect object as 'NSPoint', 'NSSize', 'NSRange' or 'NSRect' should receive the C structure" do
+    p = @o.methodReturningNSPoint
+    @o.methodAcceptingNSPoint(p).should == 1
+    p = @o.methodReturningNSSize
+    @o.methodAcceptingNSSize(p).should == 1
+    p = @o.methodReturningNSRect
+    @o.methodAcceptingNSRect(p).should == 1
+    p = @o.methodReturningNSRange
+    @o.methodAcceptingNSRange(p).should == 1
+
+    lambda { @o.methodAcceptingNSPoint(nil) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSPoint(123) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSPoint(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSPoint(@o.methodReturningNSSize) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSSize(nil) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSSize(123) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSSize(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSSize(@o.methodReturningNSPoint) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRect(nil) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRect(123) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRect(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRect(@o.methodReturningNSPoint) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRange(nil) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRange(123) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRange(Object.new) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRange(@o.methodReturningNSPoint) }.should raise_error(TypeError)
+  end
+
+  it "accepting an Array of valid objects as a structure type should receive the C structure" do
+    @o.methodAcceptingNSPoint([1, 2]).should == 1
+    @o.methodAcceptingNSSize([3, 4]).should == 1
+    @o.methodAcceptingNSRect([[1, 2], [3, 4]]).should == 1
+    @o.methodAcceptingNSRect([1, 2, 3, 4]).should == 1
+    @o.methodAcceptingNSRange([0, 42]).should == 1
+
+    lambda { @o.methodAcceptingNSPoint([1]) }.should raise_error(ArgumentError)
+    lambda { @o.methodAcceptingNSPoint([1, 2, 3]) }.should raise_error(ArgumentError)
+    lambda { @o.methodAcceptingNSRect([1, 2, 3]) }.should raise_error(ArgumentError)
+    lambda { @o.methodAcceptingNSRect([1, 2, 3, 4, 5]) }.should raise_error(ArgumentError)
+    lambda { @o.methodAcceptingNSRect([[1, 2], [3]]) }.should raise_error(ArgumentError)
+    lambda { @o.methodAcceptingNSRect([[1, 2], [3, 4, 5]]) }.should raise_error(ArgumentError)
+  end
+
+  it "accepting various C types should receive these types as expected" do
+    @o.methodAcceptingInt(42, float:42, double:42, short:42, NSPoint:[42, 42],
+                          NSRect:[42, 42, 42, 42], char:42).should == 1
+  end
+
+  it "accepting an 'int *' should be given a Pointer object and receive the pointer as expected" do
+    p = Pointer.new(:int)
+    p[0] = 42
+    @o.methodAcceptingIntPtr(p).should == 1
+    p[0].should == 43
+
+    lambda { @o.methodAcceptingIntPtr(Pointer.new(:uint)) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingIntPtr(123) }.should raise_error(TypeError)
+
+    @o.methodAcceptingIntPtr2(nil).should == 1
+
+    lambda { @o.methodAcceptingIntPtr2(Pointer.new(:uint)) }.should raise_error(TypeError)
+  end
+
+  it "accepting an 'id *' should be given a Pointer object and receive the pointer as expected" do
+    p = Pointer.new(:object)
+    p[0] = @o
+    @o.methodAcceptingObjectPtr(p).should == 1
+    p[0].should == NSObject
+
+    lambda { @o.methodAcceptingObjectPtr(Pointer.new(:int)) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingObjectPtr(123) }.should raise_error(TypeError)
+
+    @o.methodAcceptingObjectPtr2(nil).should == 1
+
+    lambda { @o.methodAcceptingObjectPtr2(Pointer.new(:int)) }.should raise_error(TypeError)
+  end
+
+  it "accepting an 'NSRect *' should be given a Pointer object and receive the pointer as expected" do
+    p = Pointer.new(NSRect.type)
+    p[0] = [1, 2, 3, 4]
+    @o.methodAcceptingNSRectPtr(p).should == 1
+    p[0].origin.x.should == 42
+    p[0].origin.y.should == 43
+    p[0].size.width.should == 44
+    p[0].size.height.should == 45
+
+    lambda { @o.methodAcceptingNSRectPtr(Pointer.new(NSPoint.type)) }.should raise_error(TypeError)
+    lambda { @o.methodAcceptingNSRectPtr(123) }.should raise_error(TypeError)
+
+    @o.methodAcceptingNSRectPtr2(nil).should == 1
+
+    lambda { @o.methodAcceptingNSRectPtr2(Pointer.new(NSPoint.type)) }.should raise_error(TypeError)
+  end
+end
+
+describe "A pure MacRuby method" do
+  before :each do
+    @o = TestMethodOverride.new
+  end
+
+  it "can overwrite an Objective-C method returning void" do
+    @o.methodReturningVoid.should == 42
+    TestMethodOverride.testMethodReturningVoid(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning self" do
+    @o.methodReturningSelf.should == @o
+    TestMethodOverride.testMethodReturningSelf(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning nil as 'id'" do
+    @o.methodReturningNil.should == nil
+    TestMethodOverride.testMethodReturningNil(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning kCFBooleanTrue as 'id'" do
+    @o.methodReturningCFTrue.should == true
+    TestMethodOverride.testMethodReturningCFTrue(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning kCFBooleanFalse as 'id'" do
+    @o.methodReturningCFFalse.should == false
+    TestMethodOverride.testMethodReturningCFFalse(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning YES as 'BOOL'" do
+    @o.methodReturningYES.should == true
+    TestMethodOverride.testMethodReturningYES(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning NO as 'BOOL'" do
+    @o.methodReturningNO.should == false
+    TestMethodOverride.testMethodReturningNO(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'unsigned char' or 'char'" do
+    @o.methodReturningChar.should == 42
+    @o.methodReturningChar2.should == -42
+    @o.methodReturningUnsignedChar.should == 42
+    TestMethodOverride.testMethodReturningChar(@o).should == 1
+    TestMethodOverride.testMethodReturningChar2(@o).should == 1
+    TestMethodOverride.testMethodReturningUnsignedChar(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'unsigned short' or 'short'" do
+    @o.methodReturningShort.should == 42
+    @o.methodReturningShort2.should == -42
+    @o.methodReturningUnsignedShort.should == 42
+    TestMethodOverride.testMethodReturningShort(@o).should == 1
+    TestMethodOverride.testMethodReturningShort2(@o).should == 1
+    TestMethodOverride.testMethodReturningUnsignedShort(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'unsigned int' or 'int'" do
+    @o.methodReturningInt.should == 42
+    @o.methodReturningInt2.should == -42
+    @o.methodReturningUnsignedInt.should == 42
+    TestMethodOverride.testMethodReturningInt(@o).should == 1
+    TestMethodOverride.testMethodReturningInt2(@o).should == 1
+    TestMethodOverride.testMethodReturningUnsignedInt(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'unsigned long' or 'long'" do
+    @o.methodReturningLong.should == 42
+    @o.methodReturningLong2.should == -42
+    @o.methodReturningUnsignedLong.should == 42
+    TestMethodOverride.testMethodReturningLong(@o).should == 1
+    TestMethodOverride.testMethodReturningLong2(@o).should == 1
+    TestMethodOverride.testMethodReturningUnsignedLong(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'float' or 'double'" do
+    @o.methodReturningFloat.should == 3.1415
+    @o.methodReturningDouble.should == 3.1415
+    TestMethodOverride.testMethodReturningFloat(@o).should == 1
+    TestMethodOverride.testMethodReturningDouble(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'SEL'" do
+    @o.methodReturningSEL.should == :'foo:with:with:'
+    @o.methodReturningSEL2.should == nil
+    TestMethodOverride.testMethodReturningSEL(@o).should == 1
+    TestMethodOverride.testMethodReturningSEL2(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'char *'" do
+    @o.methodReturningCharPtr.should == 'foo'
+    @o.methodReturningCharPtr2.should == nil
+    TestMethodOverride.testMethodReturningCharPtr(@o).should == 1
+    TestMethodOverride.testMethodReturningCharPtr2(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'NSPoint'" do
+    @o.methodReturningNSPoint.should == NSPoint.new(1, 2)
+    TestMethodOverride.testMethodReturningNSPoint(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'NSSize'" do
+    @o.methodReturningNSSize.should == NSSize.new(3, 4)
+    TestMethodOverride.testMethodReturningNSSize(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'NSRect'" do
+    @o.methodReturningNSRect.should == NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
+    TestMethodOverride.testMethodReturningNSRect(@o).should == 1
+  end
+
+  it "can overwrite an Objective-C method returning 'NSRange'" do
+    @o.methodReturningNSRange.should == NSRange.new(0, 42)
+    TestMethodOverride.testMethodReturningNSRange(@o).should == 1
+  end
+end

Deleted: MacRuby/branches/experimental/spec/macruby/method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/method_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/method_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,83 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "A pure MacRuby method" do
-  before :each do
-    @o = Object.new
-  end
-
-  it "uses argument-names + colon + variable syntax to form the method name" do
-    def @o.doSomething(x, withObject:y); x + y; end
-
-    @o.should have_method(:'doSomething:withObject:')
-    @o.should_not have_method(:'doSomething')
-  end
-
-  it "can have multiple arguments with the same name" do
-    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
-
-    @o.should have_method(:'doSomething:withObject:withObject:')
-    @o.should_not have_method(:'doSomething')
-  end
-
-  it "can coexist with other selectors whose first named argument(s) is/are the same" do
-    def @o.foo(x); x; end
-    def @o.foo(x, withObject:y); x + y; end
-    def @o.foo(x, withObject:y, withObject:z); x + y + z; end
-
-    @o.should have_method(:'foo')
-    @o.should have_method(:'foo:withObject:')
-    @o.should have_method(:'foo:withObject:withObject:')
-  end
-
-  it "must start with a regular argument variable followed by argument-names" do
-    lambda { eval("def foo(x:y); end") }.should raise_error(SyntaxError)
-    lambda { eval("def foo(x, y, with:z); end") }.should raise_error(SyntaxError)
-    lambda { eval("def foo(x, with:y, z); end") }.should raise_error(SyntaxError)
-  end
-
-  it "can be called using argument-names + colon + variable syntax" do
-    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
-    @o.doSomething(30, withObject:10, withObject:2).should == 42
-  end
-
-  it "can be called using argument-name-as-symbols + => + variable syntax" do
-    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
-    @o.doSomething(30, :withObject => 10, :withObject => 2).should == 42
-  end
-
-  it "can be called mixing both syntaxes" do
-    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
-    @o.doSomething(30, withObject:10, :withObject => 2).should == 42
-  end
-
-  it "can be called using #send" do
-    def @o.doSomething(x, withObject:y, withObject:z); x + y + z; end
-    @o.send(:'doSomething:withObject:withObject:', 30, 10, 2).should == 42
-  end
-
-  it "can be called using -[NSObject performSelector:]" do
-    def @o.doSomething; 42; end
-    @o.performSelector(:'doSomething').should == 42
-  end
-
-  it "can be called using -[NSObject performSelector:withObject:]" do
-    def @o.doSomething(x); x; end
-    @o.performSelector(:'doSomething:', withObject:42).should == 42
-  end
-
-  it "can be called using -[NSObject performSelector:withObject:withObject:]" do
-    def @o.doSomething(x, withObject:y); x + y; end
-    @o.performSelector(:'doSomething:withObject:',
-                       withObject:40, withObject:2).should == 42
-  end
-
-  it "cannot be called with #foo=, even if it matches the Objective-C #setFoo pattern" do
-    def @o.setFoo(x); end
-    @o.should_not have_method(:'foo=')
-  end
-
-  it "cannot be called with #foo?, even if it matches the Objective-C #isFoo pattern" do
-    def @o.isFoo; end
-    @o.should_not have_method(:'foo?')
-  end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/number_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/number_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/number_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,12 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "An NSNumber boolean object" do
-  it "can be compared against a true/false Ruby type" do
-    true.should == NSNumber.numberWithBool(true)
-    true.should != NSNumber.numberWithBool(false)
-    false.should == NSNumber.numberWithBool(false)
-    false.should != NSNumber.numberWithBool(true)
-  end
-end
-
-# TODO cover the Numeric interface on top of NSNumber

Deleted: MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/objc_method_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,519 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-FixtureCompiler.require! "method"
-
-require File.dirname(__FILE__) + '/fixtures/method'
-
-describe "A pure Objective-C method" do
-  before :each do
-    @o = TestMethod.new
-  end
-
-  it "can be called with #foo= if it matches the #setFoo pattern" do
-    @o.should respond_to(:'setFoo')
-    @o.should respond_to(:'foo=')
-
-    @o.setFoo(123)
-    @o.foo.should == 123
-    @o.foo = 456
-    @o.foo.should == 456
-  end
-
-  it "can be called with #foo? if it matches the #isFoo pattern" do
-    @o.should respond_to(:'isFoo')
-    @o.should respond_to(:'foo?')
-
-    @o.foo?.should equal(@o.isFoo)
-  end
-
-  it "is only exposed in #methods if the second argument is true" do
-    @o.methods.should_not include(:'performSelector')
-    @o.methods(true).should_not include(:'performSelector')
-    @o.methods(true, true).should include(:'performSelector')
-  end
-
-  it "can be called on an immediate object" do
-    123.self.should == 123
-    true.self.should == true
-    false.self.should == false
-    nil.self.should == nil
-  end
-
-  it "returning void returns nil in Ruby" do
-    @o.methodReturningVoid.should == nil
-  end
-
-  it "returning nil returns nil in Ruby" do
-    @o.methodReturningNil.should == nil
-  end
-
-  it "returning self returns the same receiver object" do
-    @o.methodReturningSelf.should == @o
-    @o.methodReturningSelf.object_id == @o.object_id
-  end
-
-  it "returning kCFBooleanTrue returns true in Ruby" do
-    @o.methodReturningCFTrue.should == true
-    @o.methodReturningCFTrue.class.should == TrueClass
-  end
-
-  it "returning kCFBooleanFalse returns false in Ruby" do
-    @o.methodReturningCFFalse.should == false
-    @o.methodReturningCFFalse.class.should == FalseClass
-  end
-
-  it "returning kCFNull returns nil in Ruby" do
-    @o.methodReturningCFNull.should == nil
-    @o.methodReturningCFNull.class.should == NilClass
-  end
-
-  it "returning YES returns true in Ruby" do
-    @o.methodReturningYES.should == true
-  end
-
-  it "returning NO returns true in Ruby" do
-    @o.methodReturningNO.should == false
-  end
-
-  it "returning 'char' or 'unsigned char' returns a Fixnum in Ruby" do
-    @o.methodReturningChar.should == 42
-    @o.methodReturningChar2.should == -42
-    @o.methodReturningUnsignedChar.should == 42
-  end
- 
-  it "returning 'short' or 'unsigned short' returns a Fixnum in Ruby" do
-    @o.methodReturningShort.should == 42
-    @o.methodReturningShort2.should == -42
-    @o.methodReturningUnsignedShort.should == 42
-  end
-
-  it "returning 'int' or 'unsigned int' returns a Fixnum in Ruby" do
-    @o.methodReturningInt.should == 42
-    @o.methodReturningInt2.should == -42
-    @o.methodReturningUnsignedInt.should == 42
-  end
-
-  it "returning 'long' or 'unsigned long' returns a Fixnum if possible in Ruby" do
-    @o.methodReturningLong.should == 42
-    @o.methodReturningLong2.should == -42
-    @o.methodReturningUnsignedLong.should == 42
-  end
-
-  it "returning 'long' or 'unsigned long' returns a Bignum if it cannot fix in a Fixnum in Ruby" do
-    @o.methodReturningLong3.should ==
-      (RUBY_ARCH == 'x86_64' ? 4611686018427387904 : 1073741824)
-    @o.methodReturningLong3.class.should == Bignum
-    @o.methodReturningLong4.should ==
-      (RUBY_ARCH == 'x86_64' ? -4611686018427387905 : -1073741825)
-    @o.methodReturningLong4.class.should == Bignum
-    @o.methodReturningUnsignedLong2.should ==
-      (RUBY_ARCH == 'x86_64' ? 4611686018427387904 : 1073741824)
-    @o.methodReturningUnsignedLong2.class.should == Bignum
-  end
-
-  it "returning 'float' returns a Float in Ruby" do
-    @o.methodReturningFloat.should be_close(3.1415, 0.0001)
-    @o.methodReturningFloat.class.should == Float
-  end
-
-  it "returning 'double' returns a Float in Ruby" do
-    @o.methodReturningDouble.should be_close(3.1415, 0.0001)
-    @o.methodReturningDouble.class.should == Float
-  end
-
-  it "returning 'SEL' returns a Symbol or nil in Ruby" do
-    @o.methodReturningSEL.class.should == Symbol
-    @o.methodReturningSEL.should == :'foo:with:with:'
-    @o.methodReturningSEL2.class.should == NilClass
-    @o.methodReturningSEL2.should == nil
-  end
-
-  it "returning 'char *' returns a String or nil in Ruby" do
-    @o.methodReturningCharPtr.class.should == String
-    @o.methodReturningCharPtr.should == 'foo'
-    @o.methodReturningCharPtr2.class.should == NilClass
-    @o.methodReturningCharPtr2.should == nil
-  end
-
-  it "returning 'NSPoint' returns an NSPoint boxed object in Ruby" do
-    b = @o.methodReturningNSPoint
-    b.class.should == NSPoint
-    b.x.class.should == Float
-    b.x.should == 1.0
-    b.y.class.should == Float
-    b.y.should == 2.0
-  end
-
-  it "returning 'NSSize' returns an NSSize boxed object in Ruby" do
-    b = @o.methodReturningNSSize
-    b.class.should == NSSize
-    b.width.class.should == Float
-    b.width.should == 3.0
-    b.height.class.should == Float
-    b.height.should == 4.0
-  end
-
-  it "returning 'NSRect' returns an NSRect boxed object in Ruby" do
-    b = @o.methodReturningNSRect
-    b.class.should == NSRect
-    b.origin.class.should == NSPoint
-    b.origin.x.should == 1.0
-    b.origin.y.should == 2.0
-    b.size.class.should == NSSize
-    b.size.width.should == 3.0
-    b.size.height.should == 4.0
-  end
-
-  it "returning 'NSRange' returns an NSRange boxed object in Ruby" do
-    b = @o.methodReturningNSRange
-    b.class.should == NSRange
-    b.location.class.should == Fixnum
-    b.location.should == 0
-    b.length.class.should == Fixnum
-    b.length.should == 42
-  end
-
-  it "accepting the receiver as 'id' should receive the exact same object" do
-    @o.methodAcceptingSelf(@o).should == 1
-  end
-
-  it "accepting the receiver's class as 'id' should receive the exact same object" do
-    @o.methodAcceptingSelfClass(@o.class).should == 1
-  end
-
-  it "accepting 'nil' as 'id' should receive Objective-C's nil" do
-    @o.methodAcceptingNil(nil).should == 1
-  end
-
-  it "accepting 'true' as 'id; should receive CF's kCFBooleanTrue" do
-    @o.methodAcceptingTrue(true).should == 1
-  end
-
-  it "accepting 'false' as 'id' should receive CF's kCFBooleanFalse" do
-    @o.methodAcceptingFalse(false).should == 1
-  end
-
-  it "accepting a Fixnum as 'id' should receive a Fixnum boxed object" do
-    @o.methodAcceptingFixnum(42).should == 1
-  end
-
-  it "accepting nil or false as 'BOOL' should receive NO, any other object should receive YES" do
-    @o.methodAcceptingFalseBOOL(nil).should == 1
-    @o.methodAcceptingFalseBOOL(false).should == 1
-
-    @o.methodAcceptingTrueBOOL(true).should == 1
-    @o.methodAcceptingTrueBOOL(0).should == 1
-    @o.methodAcceptingTrueBOOL(123).should == 1
-    @o.methodAcceptingTrueBOOL('foo').should == 1
-    @o.methodAcceptingTrueBOOL(Object.new).should == 1
-  end
-
-  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
-    @o.methodAcceptingUnsignedShort(42).should == 1
-    @o.methodAcceptingInt(42).should == 1
-    @o.methodAcceptingUnsignedInt(42).should == 1
-    @o.methodAcceptingLong(42).should == 1
-    @o.methodAcceptingUnsignedLong(42).should == 1
-
-    @o.methodAcceptingChar(42.0).should == 1
-    @o.methodAcceptingUnsignedChar(42.0).should == 1
-    @o.methodAcceptingShort(42.0).should == 1
-    @o.methodAcceptingUnsignedShort(42.0).should == 1
-    @o.methodAcceptingInt(42.0).should == 1
-    @o.methodAcceptingUnsignedInt(42.0).should == 1
-    @o.methodAcceptingLong(42.0).should == 1
-    @o.methodAcceptingUnsignedLong(42.0).should == 1
-  end
-
-  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)
-    lambda { @o.methodAcceptingUnsignedShort(nil) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingInt(nil) }.should raise_error(TypeError)
-    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)
-    lambda { @o.methodAcceptingUnsignedShort(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingInt(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingUnsignedInt(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingLong(Object.new) }.should raise_error(TypeError)
-    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
-  end
-
-  it "accepting a String, Symbol or nil as 'SEL' should receive the appropriate selector" do
-    @o.methodAcceptingSEL(:'foo:with:with:').should == 1
-    @o.methodAcceptingSEL('foo:with:with:').should == 1
-    @o.methodAcceptingSEL2(nil).should == 1
-
-    lambda { @o.methodAcceptingSEL(123) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingSEL(Object.new) }.should raise_error(TypeError)
-  end
-
-  it "accepting a Float-compatible object as 'float' or 'double' should receive the appropriate data" do
-    @o.methodAcceptingFloat(3.1415).should == 1 
-    @o.methodAcceptingDouble(3.1415).should == 1
-
-    o2 = Object.new
-    def o2.to_f; 3.1415; end
-
-    @o.methodAcceptingFloat(o2).should == 1 
-    @o.methodAcceptingDouble(o2).should == 1
-
-    lambda { @o.methodAcceptingFloat(nil) }.should raise_error(TypeError) 
-    lambda { @o.methodAcceptingDouble(nil) }.should raise_error(TypeError) 
-    lambda { @o.methodAcceptingFloat(Object.new) }.should raise_error(TypeError) 
-    lambda { @o.methodAcceptingDouble(Object.new) }.should raise_error(TypeError) 
-  end
-
-  it "accepting a String-compatible object as 'char *' should receive the appropriate data" do
-    @o.methodAcceptingCharPtr('foo').should == 1
-
-    o2 = Object.new
-    def o2.to_str; 'foo' end
-
-    @o.methodAcceptingCharPtr(o2).should == 1
-
-    lambda { @o.methodAcceptingCharPtr(123) }.should raise_error(TypeError) 
-    lambda { @o.methodAcceptingCharPtr([]) }.should raise_error(TypeError) 
-    lambda { @o.methodAcceptingCharPtr(Object.new) }.should raise_error(TypeError) 
-
-    @o.methodAcceptingCharPtr2(nil).should == 1
-  end
-
-  it "accepting an NSPoint, NSSize, NSRange or NSRect object as 'NSPoint', 'NSSize', 'NSRange' or 'NSRect' should receive the C structure" do
-    p = @o.methodReturningNSPoint
-    @o.methodAcceptingNSPoint(p).should == 1
-    p = @o.methodReturningNSSize
-    @o.methodAcceptingNSSize(p).should == 1
-    p = @o.methodReturningNSRect
-    @o.methodAcceptingNSRect(p).should == 1
-    p = @o.methodReturningNSRange
-    @o.methodAcceptingNSRange(p).should == 1
-
-    lambda { @o.methodAcceptingNSPoint(nil) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSPoint(123) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSPoint(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSPoint(@o.methodReturningNSSize) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSSize(nil) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSSize(123) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSSize(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSSize(@o.methodReturningNSPoint) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRect(nil) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRect(123) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRect(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRect(@o.methodReturningNSPoint) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRange(nil) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRange(123) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRange(Object.new) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRange(@o.methodReturningNSPoint) }.should raise_error(TypeError)
-  end
-
-  it "accepting an Array of valid objects as a structure type should receive the C structure" do
-    @o.methodAcceptingNSPoint([1, 2]).should == 1
-    @o.methodAcceptingNSSize([3, 4]).should == 1
-    @o.methodAcceptingNSRect([[1, 2], [3, 4]]).should == 1
-    @o.methodAcceptingNSRect([1, 2, 3, 4]).should == 1
-    @o.methodAcceptingNSRange([0, 42]).should == 1
-
-    lambda { @o.methodAcceptingNSPoint([1]) }.should raise_error(ArgumentError)
-    lambda { @o.methodAcceptingNSPoint([1, 2, 3]) }.should raise_error(ArgumentError)
-    lambda { @o.methodAcceptingNSRect([1, 2, 3]) }.should raise_error(ArgumentError)
-    lambda { @o.methodAcceptingNSRect([1, 2, 3, 4, 5]) }.should raise_error(ArgumentError)
-    lambda { @o.methodAcceptingNSRect([[1, 2], [3]]) }.should raise_error(ArgumentError)
-    lambda { @o.methodAcceptingNSRect([[1, 2], [3, 4, 5]]) }.should raise_error(ArgumentError)
-  end
-
-  it "accepting various C types should receive these types as expected" do
-    @o.methodAcceptingInt(42, float:42, double:42, short:42, NSPoint:[42, 42],
-                          NSRect:[42, 42, 42, 42], char:42).should == 1
-  end
-
-  it "accepting an 'int *' should be given a Pointer object and receive the pointer as expected" do
-    p = Pointer.new(:int)
-    p[0] = 42
-    @o.methodAcceptingIntPtr(p).should == 1
-    p[0].should == 43
-
-    lambda { @o.methodAcceptingIntPtr(Pointer.new(:uint)) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingIntPtr(123) }.should raise_error(TypeError)
-
-    @o.methodAcceptingIntPtr2(nil).should == 1
-
-    lambda { @o.methodAcceptingIntPtr2(Pointer.new(:uint)) }.should raise_error(TypeError)
-  end
-
-  it "accepting an 'id *' should be given a Pointer object and receive the pointer as expected" do
-    p = Pointer.new(:object)
-    p[0] = @o
-    @o.methodAcceptingObjectPtr(p).should == 1
-    p[0].should == NSObject
-
-    lambda { @o.methodAcceptingObjectPtr(Pointer.new(:int)) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingObjectPtr(123) }.should raise_error(TypeError)
-
-    @o.methodAcceptingObjectPtr2(nil).should == 1
-
-    lambda { @o.methodAcceptingObjectPtr2(Pointer.new(:int)) }.should raise_error(TypeError)
-  end
-
-  it "accepting an 'NSRect *' should be given a Pointer object and receive the pointer as expected" do
-    p = Pointer.new(NSRect.type)
-    p[0] = [1, 2, 3, 4]
-    @o.methodAcceptingNSRectPtr(p).should == 1
-    p[0].origin.x.should == 42
-    p[0].origin.y.should == 43
-    p[0].size.width.should == 44
-    p[0].size.height.should == 45
-
-    lambda { @o.methodAcceptingNSRectPtr(Pointer.new(NSPoint.type)) }.should raise_error(TypeError)
-    lambda { @o.methodAcceptingNSRectPtr(123) }.should raise_error(TypeError)
-
-    @o.methodAcceptingNSRectPtr2(nil).should == 1
-
-    lambda { @o.methodAcceptingNSRectPtr2(Pointer.new(NSPoint.type)) }.should raise_error(TypeError)
-  end
-end
-
-describe "A pure MacRuby method" do
-  before :each do
-    @o = TestMethodOverride.new
-  end
-
-  it "can overwrite an Objective-C method returning void" do
-    @o.methodReturningVoid.should == 42
-    TestMethodOverride.testMethodReturningVoid(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning self" do
-    @o.methodReturningSelf.should == @o
-    TestMethodOverride.testMethodReturningSelf(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning nil as 'id'" do
-    @o.methodReturningNil.should == nil
-    TestMethodOverride.testMethodReturningNil(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning kCFBooleanTrue as 'id'" do
-    @o.methodReturningCFTrue.should == true
-    TestMethodOverride.testMethodReturningCFTrue(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning kCFBooleanFalse as 'id'" do
-    @o.methodReturningCFFalse.should == false
-    TestMethodOverride.testMethodReturningCFFalse(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning YES as 'BOOL'" do
-    @o.methodReturningYES.should == true
-    TestMethodOverride.testMethodReturningYES(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning NO as 'BOOL'" do
-    @o.methodReturningNO.should == false
-    TestMethodOverride.testMethodReturningNO(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'unsigned char' or 'char'" do
-    @o.methodReturningChar.should == 42
-    @o.methodReturningChar2.should == -42
-    @o.methodReturningUnsignedChar.should == 42
-    TestMethodOverride.testMethodReturningChar(@o).should == 1
-    TestMethodOverride.testMethodReturningChar2(@o).should == 1
-    TestMethodOverride.testMethodReturningUnsignedChar(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'unsigned short' or 'short'" do
-    @o.methodReturningShort.should == 42
-    @o.methodReturningShort2.should == -42
-    @o.methodReturningUnsignedShort.should == 42
-    TestMethodOverride.testMethodReturningShort(@o).should == 1
-    TestMethodOverride.testMethodReturningShort2(@o).should == 1
-    TestMethodOverride.testMethodReturningUnsignedShort(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'unsigned int' or 'int'" do
-    @o.methodReturningInt.should == 42
-    @o.methodReturningInt2.should == -42
-    @o.methodReturningUnsignedInt.should == 42
-    TestMethodOverride.testMethodReturningInt(@o).should == 1
-    TestMethodOverride.testMethodReturningInt2(@o).should == 1
-    TestMethodOverride.testMethodReturningUnsignedInt(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'unsigned long' or 'long'" do
-    @o.methodReturningLong.should == 42
-    @o.methodReturningLong2.should == -42
-    @o.methodReturningUnsignedLong.should == 42
-    TestMethodOverride.testMethodReturningLong(@o).should == 1
-    TestMethodOverride.testMethodReturningLong2(@o).should == 1
-    TestMethodOverride.testMethodReturningUnsignedLong(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'float' or 'double'" do
-    @o.methodReturningFloat.should == 3.1415
-    @o.methodReturningDouble.should == 3.1415
-    TestMethodOverride.testMethodReturningFloat(@o).should == 1
-    TestMethodOverride.testMethodReturningDouble(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'SEL'" do
-    @o.methodReturningSEL.should == :'foo:with:with:'
-    @o.methodReturningSEL2.should == nil
-    TestMethodOverride.testMethodReturningSEL(@o).should == 1
-    TestMethodOverride.testMethodReturningSEL2(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'char *'" do
-    @o.methodReturningCharPtr.should == 'foo'
-    @o.methodReturningCharPtr2.should == nil
-    TestMethodOverride.testMethodReturningCharPtr(@o).should == 1
-    TestMethodOverride.testMethodReturningCharPtr2(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'NSPoint'" do
-    @o.methodReturningNSPoint.should == NSPoint.new(1, 2)
-    TestMethodOverride.testMethodReturningNSPoint(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'NSSize'" do
-    @o.methodReturningNSSize.should == NSSize.new(3, 4)
-    TestMethodOverride.testMethodReturningNSSize(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'NSRect'" do
-    @o.methodReturningNSRect.should == NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
-    TestMethodOverride.testMethodReturningNSRect(@o).should == 1
-  end
-
-  it "can overwrite an Objective-C method returning 'NSRange'" do
-    @o.methodReturningNSRange.should == NSRange.new(0, 42)
-    TestMethodOverride.testMethodReturningNSRange(@o).should == 1
-  end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/objc_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/objc_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/objc_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,46 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-# TODO: the MacRuby class should also be tested from Objective-C.
-#FixtureCompiler.require! "objc"
-
-describe "-[MacRuby sharedRuntime]" do
-  before :each do
-    @r = MacRuby.sharedRuntime
-  end
-
-  it "initializes and return a singleton instance representing the runtime" do
-    @r.class.should == MacRuby
-    @r.should == MacRuby.sharedRuntime
-  end
-
-  it "can evaluate a given Ruby expression" do
-    o = @r.evaluateString('1+2')
-    o.class.should == Fixnum
-    o.should == 3
-
-    lambda { @r.evaluateString('1+') }.should raise_error(SyntaxError)
-    lambda { @r.evaluateString('foo') }.should raise_error(NameError)
-  end
-
-  it "can evaluate a given Ruby file using a path or an URL" do
-    p1 = File.dirname(__FILE__) + '/fixtures/test_objc1.rb'
-    p2 = File.dirname(__FILE__) + '/fixtures/test_objc2.rb'
-
-    o = @r.evaluateFileAtPath(p1)
-    o.class.should == Fixnum
-    o.should == 3
-
-    o = @r.evaluateFileAtURL(NSURL.fileURLWithPath(p1))
-    o.class.should == Fixnum
-    o.should == 3
-
-    lambda { @r.evaluateFileAtPath(p2) }.should raise_error(NameError)
-    lambda { @r.evaluateFileAtURL(NSURL.fileURLWithPath(p2)) }.should raise_error(NameError)
-
-    # TODO: add tests that should raise_error for the following cases:
-    # - given path is nil
-    # - given path does not exist
-    # - given URL is nil
-    # - given file:// URL does not exist
-    # - given URL is not file://
-  end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/opaque_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/opaque_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/opaque_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,32 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "A BridgeSupport opaque type" do
-  it "is an instance of Boxed" do
-    NSZone.superclass.should == Boxed
-  end
-
-  it "cannot be created with #new" do
-    lambda { NSZone.new }.should raise_error(RuntimeError)
-  end
-
-  it "can be created from an Objective-C API, and passed back to Objective-C" do
-    z = 123.zone
-    z.class.should == NSZone
-    lambda { Object.allocWithZone(z).init }.should_not raise_error
-    lambda { Object.allocWithZone(nil).init }.should_not raise_error
-    lambda { Object.allocWithZone(123).init }.should raise_error(TypeError)
-    lambda { Object.allocWithZone(NSPoint.new).init }.should raise_error(TypeError)
-  end
-
-  it "can be compared to an exact same instance using #==" do
-    123.zone.should == 456.zone
-  end
-
-  it "returns true when the #opaque? class method is called" do
-    NSZone.opaque?.should == true
-  end 
-
-  it "returns its Objective-C encoding type when then #type class method is called" do
-    NSZone.type.should == '^{_NSZone=}'
-  end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/pointer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/pointer_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/pointer_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,114 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "A Pointer object, when initializing" do
-  before :all do
-    @types = {
-      :object     => '@',
-      :char       => 'c',
-      :uchar      => 'C',
-      :short      => 's',
-      :ushort     => 'S',
-      :int        => 'i',
-      :uint       => 'I',
-      :long       => 'l',
-      :ulong      => 'L',
-      :long_long  => 'q',
-      :ulong_long => 'Q',
-      :float      => 'f',
-      :double     => 'd'
-    }
-  end
-
-  it "accepts a valid Objective-C type string" do
-    @types.values.each do |type|
-      lambda { @pointer = Pointer.new(type) }.should_not raise_error
-      @pointer.type.should == type
-    end
-  end
-
-  it "accepts a Symbol argument which responds to a valid Objective-C type" do
-    @types.each do |symbol, type|
-      lambda { @pointer = Pointer.new(symbol) }.should_not raise_error
-      @pointer.type.should == type
-    end
-  end
-
-  it "raises an ArgumentError when no argument is given" do
-    lambda { Pointer.new }.should raise_error(ArgumentError)
-  end
-
-  it "raises a TypeError when a incompatible object is given" do
-    lambda { Pointer.new(nil) }.should raise_error(TypeError)
-    lambda { Pointer.new(123) }.should raise_error(TypeError)
-    lambda { Pointer.new('x') }.should raise_error(TypeError)
-  end
-
-  it "accepts the type returned by NSRect" do
-    Pointer.new(NSRect.type).type.should == NSRect.type
-  end
-end
-
-describe "Pointer, through #[] and #[]=" do
-  integer_types = %w{ char uchar short ushort int uint long ulong long_long ulong_long }
-  float_types   = %w{ float double }
-
-  structs       = [NSPoint.new(1, 2), NSSize.new(3, 4), NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))]
-  struct_types  = structs.map { |x| x.class.type }
-  structs       = structs.zip(struct_types)
-
-  it "can assign and retrieve any object with type `object'" do
-    pointer = Pointer.new('object')
-    [Object.new, 123].each do |object|
-      pointer[0] = object
-      pointer[0].should == object
-      pointer[0].should be_kind_of(object.class)
-    end
-  end
-
-  integer_types.each do |type|
-    it "can assign and retrieve Fixnum compatible objects for type `#{type}'" do
-      pointer = Pointer.new(type)
-
-      coercable_object = Object.new
-      def coercable_object.to_i; 42; end
-
-      [42, coercable_object].each do |object|
-        pointer[0] = object
-        pointer[0].should == 42
-        pointer[0].should be_kind_of(Fixnum)
-      end
-    end
-  end
-  
-  float_types.each do |type|
-    it "can assign and retrieve Float compatible objects for type `#{type}'" do
-      pointer = Pointer.new(type)
-
-      coercable_object = Object.new
-      def coercable_object.to_f; 42.0; end
-
-      [42, coercable_object].each do |object|
-        pointer[0] = object
-        pointer[0].should == 42.0
-        pointer[0].should be_kind_of(Float)
-      end
-    end
-  end
-
-  structs.each do |struct, type|
-    it "can assign and retrieve #{struct.class.name} objects for type `#{type}'" do
-      pointer = Pointer.new(type)
-
-      pointer[0] = struct
-      pointer[0].should == struct
-      pointer[0].should be_kind_of(struct.class)
-    end
-  end
-
-  (integer_types + float_types + struct_types).each do |type|
-    it "raises a TypeError when assigned an object not of type `#{type}'" do
-      pointer = Pointer.new(type)
-      lambda { pointer[0] = Object.new }.should raise_error(TypeError)
-    end
-  end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/string_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/string_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/string_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,71 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "The String class" do
-  it "is an alias to NSMutableString" do
-    String.should == NSMutableString
-  end
-
-  it "can be subclassed and later instantiated" do
-    k = Class.new(String)
-    a = k.new
-    a.class.should == k
-    a << 'foo'
-    a.should == 'foo'
-  end
-end
-
-=begin
-describe "The NSString class" do
-  it "can be subclassed and later instantiated" do
-    k = Class.new(NSString)
-    a = k.new
-    a.class.should == k
-    a.size.should == 0
-    lambda { a << 'foo' }.should raise_error(RuntimeError)
-  end
-end
-=end
-
-describe "An String object" do
-  it "is an instance of the String/NSMutableString class" do
-    ''.class.should == String
-    ''.kind_of?(String).should == true
-    ''.instance_of?(String).should == true
-  end
-
-  it "is mutable" do
-    a = ''
-    a << 'foo'
-    a.should == 'foo'
-  end
-
-  it "can have a singleton class" do
-    a = ''
-    def a.foo; 42; end
-    a.foo.should == 42
-    a << 'foo'
-    a.should == 'foo'
-  end
-end
-
-describe "An NSString object" do
-  it "is an instance of the NSString class" do
-    a = NSString.string
-    a.class.should == NSString
-  end
-
-  it "is immutable" do
-    a = NSString.string
-    a.size.should == 0
-    lambda { a << 'foo' }.should raise_error(RuntimeError)
-  end
-
-=begin
-  it "can have a singleton class" do
-    a = NSString.string
-    def a.foo; 42; end
-    a.foo.should == 42
-    lambda { a << 'foo' }.should raise_error(RuntimeError)
-  end
-=end
-end

Deleted: MacRuby/branches/experimental/spec/macruby/struct_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/macruby/struct_spec.rb	2009-05-21 00:10:11 UTC (rev 1581)
+++ MacRuby/branches/experimental/spec/macruby/struct_spec.rb	2009-05-21 09:08:45 UTC (rev 1582)
@@ -1,215 +0,0 @@
-require File.dirname(__FILE__) + "/spec_helper"
-
-describe "A BridgeSupport structure" do
-  it "is an instance of Boxed" do
-    NSPoint.superclass.should == Boxed
-    NSSize.superclass.should == Boxed
-    NSRect.superclass.should == Boxed
-    NSRange.superclass.should == Boxed
-  end
-
-  it "can be created with null values using the #new method with no argument" do
-    o = NSPoint.new
-    o.x.class.should == Float
-    o.y.class.should == Float
-    o.x.should == 0.0
-    o.y.should == 0.0
-
-    o = NSRect.new
-    o.origin.class.should == NSPoint
-    o.origin.x.class.should == Float
-    o.origin.y.class.should == Float
-    o.origin.x.should == 0.0
-    o.origin.y.should == 0.0
-    o.size.class.should == NSSize
-    o.size.width.class.should == Float
-    o.size.height.class.should == Float
-    o.size.width.should == 0.0
-    o.size.height.should == 0.0
-  end
-
-  it "can be created with given values using the #new method with arguments" do
-    o = NSPoint.new(1.0, 2.0)
-    o.y.class.should == Float
-    o.x.class.should == Float
-    o.x.should == 1.0
-    o.y.should == 2.0
-
-    o = NSPoint.new(1, 2)
-    o.x.class.should == Float
-    o.y.class.should == Float
-    o.x.should == 1.0
-    o.y.should == 2.0
-
-    fix1 = Object.new; def fix1.to_f; 1.0; end
-    fix2 = Object.new; def fix2.to_f; 2.0; end
-
-    o = NSPoint.new(fix1, fix2)
-    o.x.class.should == Float
-    o.y.class.should == Float
-    o.x.should == 1.0
-    o.y.should == 2.0
-
-    lambda { NSPoint.new(1) }.should raise_error(ArgumentError) 
-    lambda { NSPoint.new(1, 2, 3) }.should raise_error(ArgumentError)
-    lambda { NSPoint.new(Object.new, 42) }.should raise_error(TypeError)
-    lambda { NSPoint.new(nil, nil) }.should raise_error(TypeError)
-
-    o = NSRect.new(NSPoint.new(1, 2), NSSize.new(3, 4))
-    o.origin.class.should == NSPoint
-    o.origin.x.class.should == Float
-    o.origin.y.class.should == Float
-    o.origin.x == 1.0
-    o.origin.y == 2.0
-    o.size.class.should == NSSize
-    o.size.width.class.should == Float
-    o.size.height.class.should == Float
-    o.size.width == 3.0
-    o.size.height == 4.0
-
-    lambda { NSRect.new(1) }.should raise_error(ArgumentError)
-    lambda { NSRect.new(1, 2) }.should raise_error(TypeError)
-    lambda { NSRect.new(1, 2, 3) }.should raise_error(ArgumentError)
-    lambda { NSRect.new(1, 2, 3, 4) }.should raise_error(ArgumentError)
-    lambda { NSRect.new(NSSize.new, NSPoint.new) }.should raise_error(TypeError)
-    lambda { NSRect.new(nil, nil) }.should raise_error(TypeError)
-  end
-
-  it "has accessors for every field" do
-    p = NSPoint.new
-    p.x = 1
-    p.y = 2
-    p.x.class.should == Float
-    p.y.class.should == Float
-    p.x.should == 1.0
-    p.y.should == 2.0
-
-    s = NSSize.new
-    s.width = 3
-    s.height = 4
-    s.width.class.should == Float
-    s.height.class.should == Float
-    s.width.should == 3.0
-    s.height.should == 4.0
-
-    r = NSRect.new
-    r.origin = p
-    r.size = s
-    r.origin.class.should == NSPoint
-    r.size.class.should == NSSize
-
-    lambda { r.origin = nil }.should raise_error(TypeError)
-    lambda { r.origin = Object.new }.should raise_error(TypeError)
-
-    r.origin = [123, 456]
-    r.size = [789, 100]
-    
-    r.origin.x.class.should == Float
-    r.origin.y.class.should == Float
-    r.size.width.class.should == Float
-    r.size.height.class.should == Float
-    r.origin.x.should == 123.0
-    r.origin.y.should == 456.0
-    r.size.width.should == 789.0
-    r.size.height.should == 100.0
-  end
-
-  it "can be compared to another similar object using #==" do
-    p1 = NSPoint.new(1, 2)
-    p2 = NSPoint.new(3, 4)
-    p1.should_not == p2
-
-    p2.x = 1
-    p2.y = 2
-    p1.should == p2
-
-    r1 = NSRect.new
-    r2 = NSRect.new
-    r1.should == r2
-
-    r1.origin = NSPoint.new(1, 2)
-    r1.size = NSSize.new(3, 4)
-    r2.origin = NSPoint.new(1, 2)
-    r2.size = NSSize.new(3, 42)
-    r1.should_not == r2
-
-    r2.size.height = 4
-    r1.should == r2
-
-    NSPoint.new.should_not == nil
-    NSPoint.new.should_not == 123
-    NSPoint.new.should_not == [0, 0]
-    NSPoint.new.should_not == [0.0, 0.0]
-    NSPoint.new.should_not == NSSize.new
-  end
-
-  it "has a nice #inspect message that lists the fields" do
-    p = NSPoint.new
-    p.inspect.should == "#<CGPoint x=0.0 y=0.0>"
-    p.x = 1
-    p.y = 2
-    p.inspect.should == "#<CGPoint x=1.0 y=2.0>"
-
-    s = NSSize.new(3, 4)
-    s.inspect.should == "#<CGSize width=3.0 height=4.0>"
-
-    r = NSRect.new
-    r.inspect.should == "#<CGRect origin=#<CGPoint x=0.0 y=0.0> size=#<CGSize width=0.0 height=0.0>>"
-    r.origin = p
-    r.inspect.should == "#<CGRect origin=#<CGPoint x=1.0 y=2.0> size=#<CGSize width=0.0 height=0.0>>"
-    r.size = s
-    r.inspect.should == "#<CGRect origin=#<CGPoint x=1.0 y=2.0> size=#<CGSize width=3.0 height=4.0>>"
-  end
-
-  it "can be duplicated using #dup or #clone" do
-    p = NSPoint.new(1, 2)
-    p.should == p.dup
-    p.should == p.clone
-
-    p2 = p.dup
-    p2.x = 42
-    p2.should_not == p
-
-    r = NSRect.new
-    r.origin.x = 1
-    r.origin.y = 2
-    r2 = r.dup
-    r.size.width = 3.0
-    r.size.height = 4.0
-    r2.size = NSSize.new(3, 4)
-    r.should == r2
-  end
-
-  it "returns the list of fields when the #fields class method is called" do
-    NSPoint.fields.should == [:x, :y]
-    NSSize.fields.should == [:width, :height]
-    NSRect.fields.should == [:origin, :size]
-  end
-
-  it "returns false when the #opaque? class method is called" do
-    NSPoint.opaque?.should == false
-    NSSize.opaque?.should == false
-    NSRect.opaque?.should == false
-  end
-
-  it "returns its Objective-C encoding type when then #type class method is called" do
-    if RUBY_ARCH == 'x86_64'
-      NSPoint.type.should == '{CGPoint=dd}'
-      NSSize.type.should == '{CGSize=dd}'
-      NSRect.type.should == '{CGRect={CGPoint=dd}{CGSize=dd}}'
-    else
-      NSPoint.type.should == '{_NSPoint=ff}'
-      NSSize.type.should == '{_NSSize=ff}'
-      NSRect.type.should == '{_NSRect={_NSPoint=ff}{_NSSize=ff}}'
-    end
-  end
-
-  it "defined after a structure which has the same type is an alias to the other structure class" do
-    NSPoint.should == CGPoint
-    NSSize.should == CGSize
-    NSRect.should == CGRect
-    NSPoint.object_id.should == CGPoint.object_id
-    NSSize.object_id.should == CGSize.object_id
-    NSRect.object_id.should == CGRect.object_id
-  end
-end

Added: MacRuby/branches/experimental/spec/macruby/tags/macruby/core/number_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/macruby/tags/macruby/core/number_tags.txt	                        (rev 0)
+++ MacRuby/branches/experimental/spec/macruby/tags/macruby/core/number_tags.txt	2009-05-21 09:08:45 UTC (rev 1582)
@@ -0,0 +1 @@
+fails:An NSNumber boolean object can be compared against a true/false Ruby type
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090521/08cb823b/attachment-0001.html>


More information about the macruby-changes mailing list