Revision: 3660 http://trac.macosforge.org/projects/ruby/changeset/3660 Author: eloy.de.enige@gmail.com Date: 2010-02-28 06:53:20 -0800 (Sun, 28 Feb 2010) Log Message: ----------- Delegate #copyWithZone to #dup, as we don't do anything with the zone yet. Modified Paths: -------------- MacRuby/trunk/class.c MacRuby/trunk/spec/macruby/core/object_spec.rb Modified: MacRuby/trunk/class.c =================================================================== --- MacRuby/trunk/class.c 2010-02-28 14:53:09 UTC (rev 3659) +++ MacRuby/trunk/class.c 2010-02-28 14:53:20 UTC (rev 3660) @@ -67,15 +67,13 @@ return (void *)rb_robject_allocate_instance((VALUE)rcv); } -VALUE rb_obj_init_copy(VALUE, SEL, VALUE); - static void * rb_obj_imp_copyWithZone(void *rcv, SEL sel, void *zone) { // XXX honor zone? - VALUE copy = rb_robject_allocate_instance(CLASS_OF(rcv)); - rb_obj_init_copy(copy, 0, (VALUE)rcv); - return (void *)copy; + // for now let rb_obj_dup allocate an instance, since we don't honor the + // zone yet anyways + return (void *)rb_obj_dup((VALUE)rcv); } static BOOL @@ -129,6 +127,8 @@ return rb_class_real(cl); } +VALUE rb_obj_init_copy(VALUE, SEL, VALUE); + void rb_define_object_special_methods(VALUE klass) { Modified: MacRuby/trunk/spec/macruby/core/object_spec.rb =================================================================== --- MacRuby/trunk/spec/macruby/core/object_spec.rb 2010-02-28 14:53:09 UTC (rev 3659) +++ MacRuby/trunk/spec/macruby/core/object_spec.rb 2010-02-28 14:53:20 UTC (rev 3660) @@ -1,7 +1,8 @@ require File.dirname(__FILE__) + "/../spec_helper" +require File.expand_path('../../../frozen/core/object/shared/dup_clone', __FILE__) + FixtureCompiler.require! "object" TestObject # force dynamic load - require File.join(FIXTURES, 'object') describe "A pure MacRuby Class" do @@ -25,3 +26,29 @@ o.initialized?.should == true end end + +# Atm we don't actually do anything with the given zone, so the current +# implementation behaves exactly like #dup. Hence, we can reuse the existing +# rubyspec specs for Object#dup. +# +# But since #dup does not take an argument, we stub the spec classes to call +# #copyWithZone from a method that doesn't take an argument either. +module ObjectSpecCopyWithZone + def copyWithZoneWithoutActualZone + copyWithZone(nil) + end +end +ObjectSpecDup.send(:include, ObjectSpecCopyWithZone) +ObjectSpecDupInitCopy.send(:include, ObjectSpecCopyWithZone) + +describe "Object#copyWithZone:" do + it_behaves_like :object_dup_clone, :copyWithZoneWithoutActualZone + + it "does not preserve frozen state from the original" do + o = ObjectSpecDupInitCopy.new + o.freeze + o2 = o.copyWithZone(nil) + + o2.frozen?.should == false + end +end \ No newline at end of file
participants (1)
-
source_changes@macosforge.org