Skip to content

Commit

Permalink
Add a spec for Pointer#to_object
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrous26 committed Jun 26, 2011
1 parent e994638 commit a6c7ffb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spec/macruby/core/pointer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def coercable_object.to_i; 42; end
end
end
end

float_types.each do |type|
it "can assign and retrieve Float compatible objects for type `#{type}'" do
pointer = Pointer.new(type)
Expand Down Expand Up @@ -221,6 +221,14 @@ def coercable_object.to_f; 42.0; end
ptr3.class.should == Pointer
10.times { |i| ptr3[i].should == i }
end

it "responds to #to_object which returns a copy of self casted to an objective-c object" do
keyboard = TISCopyCurrentKeyboardInputSource()
name = TISGetInputSourceProperty(keyboard, KTISPropertyLocalizedName)
name.to_object.should be_an_instance_of String
name.should be_an_instance_of Pointer
# invalid use of #to_object will crash MacRuby, so we can't really test that
end
end

describe "A pointer magic cookie" do
Expand Down

0 comments on commit a6c7ffb

Please sign in to comment.