Add test to ensure we always convert Pointer instances.

This commit is contained in:
Eloy Durán
2014-05-08 16:52:06 +02:00
parent 7af49d2787
commit c411237b64
5 changed files with 24 additions and 9 deletions

View File

@@ -6,3 +6,16 @@ describe "Pointer" do
TestMethod.testPointerToStrings(ptr, length:vals.size).should == vals.inject(0) { |m, v| m + v }
end
end
describe "Void-pointers" do
it "does not try to convert an object" do
obj = Object.new
TestVoidPointer.methodWithObjectVoidPointer(obj).should == obj
end
it "does convert a Pointer to the actual data" do
pointer = Pointer.new('i')
pointer[0] = 42
TestVoidPointer.methodWithCTypeVoidPointer(pointer).should == 42
end
end

View File

@@ -30,9 +30,3 @@ describe "BOOL Type Encoding" do
end
end
describe "Void-pointers" do
it "does not try to convert an object with a type of `void *`" do
obj = Object.new
TestVoidPointer.methodWithVoidPointer(obj).should == obj
end
end

View File

@@ -125,5 +125,6 @@ typedef struct MyUnionHasBool {
@end
@interface TestVoidPointer : NSObject
+ (id)methodWithVoidPointer:(void *)object;
+ (id)methodWithObjectVoidPointer:(void *)object;
+ (int)methodWithCTypeVoidPointer:(void *)val;
@end

View File

@@ -210,8 +210,15 @@ ReturnsIntBlock KreateGlobalBlock()
@end
@implementation TestVoidPointer
+ (id)methodWithVoidPointer:(void *)object;
+ (id)methodWithObjectVoidPointer:(void *)object;
{
return (id)object;
}
+ (int)methodWithCTypeVoidPointer:(void *)val;
{
return *(int *)val;
}
@end

2
vm

Submodule vm updated: 42e6b7b0cd...7221714a2e