[macruby-changes] [4831] MacRuby/trunk/spec/macruby/core/pointer_spec.rb

source_changes at macosforge.org source_changes at macosforge.org
Tue Oct 26 15:40:37 PDT 2010


Revision: 4831
          http://trac.macosforge.org/projects/ruby/changeset/4831
Author:   lsansonetti at apple.com
Date:     2010-10-26 15:40:35 -0700 (Tue, 26 Oct 2010)
Log Message:
-----------
update specs after Pointer.new changes

Modified Paths:
--------------
    MacRuby/trunk/spec/macruby/core/pointer_spec.rb

Modified: MacRuby/trunk/spec/macruby/core/pointer_spec.rb
===================================================================
--- MacRuby/trunk/spec/macruby/core/pointer_spec.rb	2010-10-26 22:40:17 UTC (rev 4830)
+++ MacRuby/trunk/spec/macruby/core/pointer_spec.rb	2010-10-26 22:40:35 UTC (rev 4831)
@@ -5,8 +5,11 @@
     @types = {
       :object     => '@',
       :id         => '@',
+      :class      => '#',
       :boolean    => 'B',
       :bool       => 'B',
+      :selector   => ':',
+      :sel        => ':',
       :char       => 'c',
       :uchar      => 'C',
       :short      => 's',
@@ -29,7 +32,7 @@
     end
   end
 
-  it "accepts a Symbol argument which responds to a valid Objective-C type" do
+  it "accepts a Symbol argument as a type shortcut" do
     @types.each do |symbol, type|
       lambda { @pointer = Pointer.new(symbol) }.should_not raise_error
       @pointer.type.should == type
@@ -40,6 +43,9 @@
     lambda { Pointer.new }.should raise_error(ArgumentError)
   end
 
+  it "raises an ArgumentError when a given Symbol is an invalid type shortcut" do    lambda { Pointer.new(:foo) }.should raise_error(TypeError)
+  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)
@@ -61,15 +67,15 @@
 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 }
+  integer_types = %w{ char uchar short ushort int uint long ulong long_long ulong_long }.map { |x| x.intern }
+  float_types   = %w{ float double }.map { |x| x.intern }
 
   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')
+    pointer = Pointer.new(:object)
     [Object.new, 123].each do |object|
       pointer[0] = object
       pointer[0].should == object
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101026/639fd6e2/attachment.html>


More information about the macruby-changes mailing list