@@ -886,74 +886,78 @@ def reach
886
886
o . instance_variables . should == [ ]
887
887
end
888
888
end
889
+ end
889
890
890
- describe "allocator accessors" do
891
- describe "rb_define_alloc_func" do
892
- it "sets up the allocator" do
893
- klass = Class . new
894
- @o . rb_define_alloc_func ( klass )
895
- obj = klass . allocate
896
- obj . class . should . equal? ( klass )
897
- obj . should have_instance_variable ( :@from_custom_allocator )
898
- end
891
+ describe "allocator accessors" do
892
+ describe "rb_define_alloc_func" do
893
+ it "sets up the allocator" do
894
+ klass = Class . new
895
+ @o . rb_define_alloc_func ( klass )
896
+ obj = klass . allocate
897
+ obj . class . should . equal? ( klass )
898
+ obj . should have_instance_variable ( :@from_custom_allocator )
899
+ end
899
900
900
- it "sets up the allocator for a subclass of String" do
901
- klass = Class . new ( String )
902
- @o . rb_define_alloc_func ( klass )
903
- obj = klass . allocate
904
- obj . class . should . equal? ( klass )
905
- obj . should have_instance_variable ( :@from_custom_allocator )
906
- obj . should == ""
907
- end
901
+ it "sets up the allocator for a subclass of String" do
902
+ klass = Class . new ( String )
903
+ @o . rb_define_alloc_func ( klass )
904
+ obj = klass . allocate
905
+ obj . class . should . equal? ( klass )
906
+ obj . should have_instance_variable ( :@from_custom_allocator )
907
+ obj . should == ""
908
+ end
908
909
909
- it "sets up the allocator for a subclass of Array" do
910
- klass = Class . new ( Array )
911
- @o . rb_define_alloc_func ( klass )
912
- obj = klass . allocate
913
- obj . class . should . equal? ( klass )
914
- obj . should have_instance_variable ( :@from_custom_allocator )
915
- obj . should == [ ]
916
- end
910
+ it "sets up the allocator for a subclass of Array" do
911
+ klass = Class . new ( Array )
912
+ @o . rb_define_alloc_func ( klass )
913
+ obj = klass . allocate
914
+ obj . class . should . equal? ( klass )
915
+ obj . should have_instance_variable ( :@from_custom_allocator )
916
+ obj . should == [ ]
917
917
end
918
+ end
918
919
919
- describe "rb_get_alloc_func" do
920
- it "gets the allocator that is defined directly on a class" do
921
- klass = Class . new
922
- @o . rb_define_alloc_func ( klass )
923
- @o . speced_allocator? ( Object ) . should be_false
924
- @o . speced_allocator? ( klass ) . should be_true
925
- end
920
+ describe "rb_get_alloc_func" do
921
+ it "gets the allocator that is defined directly on a class" do
922
+ klass = Class . new
923
+ @o . rb_define_alloc_func ( klass )
924
+ @o . speced_allocator? ( Object ) . should == false
925
+ @o . speced_allocator? ( klass ) . should == true
926
+ end
926
927
927
- it "gets the allocator that is inherited" do
928
- parent = Class . new
929
- @o . rb_define_alloc_func ( parent )
930
- klass = Class . new ( parent )
931
- @o . speced_allocator? ( Object ) . should be_false
932
- @o . speced_allocator? ( klass ) . should be_true
933
- end
928
+ it "gets the allocator that is inherited" do
929
+ parent = Class . new
930
+ @o . rb_define_alloc_func ( parent )
931
+ klass = Class . new ( parent )
932
+ @o . speced_allocator? ( Object ) . should == false
933
+ @o . speced_allocator? ( klass ) . should == true
934
934
end
935
+ end
935
936
936
- describe "rb_undef_alloc_func" do
937
- it "does nothing when called on a class without a custom allocator" do
938
- -> { @o . allocator_nil? ( Class . new ) } . should_not raise_error
939
- end
937
+ describe "rb_undef_alloc_func" do
938
+ it "makes rb_get_alloc_func() return NULL for a class without a custom allocator" do
939
+ klass = Class . new
940
+ @o . rb_undef_alloc_func ( klass )
941
+ @o . custom_alloc_func? ( klass ) . should == false
942
+ end
940
943
941
- it "undefs the allocator for the class" do
942
- klass = Class . new
943
- @o . rb_define_alloc_func ( klass )
944
- @o . speced_allocator? ( klass ) . should be_true
945
- @o . rb_undef_alloc_func ( klass )
946
- @o . allocator_nil ?( klass ) . should be_true
947
- end
944
+ it "undefs the allocator for the class" do
945
+ klass = Class . new
946
+ @o . rb_define_alloc_func ( klass )
947
+ @o . speced_allocator? ( klass ) . should == true
948
+ @o . rb_undef_alloc_func ( klass )
949
+ @o . custom_alloc_func ?( klass ) . should == false
950
+ end
948
951
949
- it "undefs the allocator for a class that inherits a allocator" do
950
- parent = Class . new
951
- @o . rb_define_alloc_func ( parent )
952
- klass = Class . new ( parent )
953
- @o . speced_allocator? ( klass ) . should be_true
954
- @o . rb_undef_alloc_func ( klass )
955
- @o . allocator_nil? ( klass ) . should be_true
956
- end
952
+ it "undefs the allocator for a class that inherits a allocator" do
953
+ parent = Class . new
954
+ @o . rb_define_alloc_func ( parent )
955
+ klass = Class . new ( parent )
956
+ @o . speced_allocator? ( klass ) . should == true
957
+ @o . rb_undef_alloc_func ( klass )
958
+ @o . custom_alloc_func? ( klass ) . should == false
959
+
960
+ @o . speced_allocator? ( parent ) . should == true
957
961
end
958
962
end
959
963
end
0 commit comments