[macruby-changes] [4829] MacRuby/trunk/spec/macruby/core/pointer_spec.rb
source_changes at macosforge.org
source_changes at macosforge.org
Mon Oct 25 18:48:09 PDT 2010
Revision: 4829
http://trac.macosforge.org/projects/ruby/changeset/4829
Author: lsansonetti at apple.com
Date: 2010-10-25 18:48:07 -0700 (Mon, 25 Oct 2010)
Log Message:
-----------
add some specs for Pointer#{+,-}
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 00:38:20 UTC (rev 4828)
+++ MacRuby/trunk/spec/macruby/core/pointer_spec.rb 2010-10-26 01:48:07 UTC (rev 4829)
@@ -198,4 +198,21 @@
ptr[2].should == 111
ptr[3].should == 0
end
+
+ it "respond to #+ and #- which will respectively return a new Pointer object based on the appropriate offset" do
+ ptr = Pointer.new(:long, 10)
+ 10.times { |i| ptr[i] = i }
+ ptr2 = ptr + 5;
+ ptr2.class.should == Pointer
+ ptr2[0].should == 5
+ ptr2[1].should == 6
+ ptr2[2].should == 7
+ ptr2[3].should == 8
+ ptr2[4].should == 9
+ lambda { ptr2[5] }.should raise_error(ArgumentError)
+ lambda { ptr2 + 6 }.should raise_error(ArgumentError)
+ ptr3 = ptr2 - 5
+ ptr3.class.should == Pointer
+ 10.times { |i| ptr3[i].should == i }
+ end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101025/3bc97897/attachment.html>
More information about the macruby-changes
mailing list