Skip to content

Commit

Permalink
added specs for Pointer#cast!
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@3946 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
lrz committed Apr 20, 2010
1 parent 76a49e4 commit 48e8a05
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/macruby/core/pointer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,19 @@ def coercable_object.to_f; 42.0; end
lambda { pointer[3] = 42 }.should raise_error(ArgumentError)
end
end

describe "A Pointer object" do
it "can have its type changed using #cast!" do
pointer = Pointer.new(NSRect.type)
pointer[0] = NSMakeRect(10, 20, 30, 40)

val = NSValue.valueWithPointer(pointer)
pointer2 = val.pointerValue
pointer2.class.should == Pointer
pointer2.type == 'v'

pointer2.cast!(NSRect.type).should == pointer2
pointer2.type.should == NSRect.type
pointer2[0].should == NSMakeRect(10, 20, 30, 40)
end
end

0 comments on commit 48e8a05

Please sign in to comment.