1 // TEST_CFLAGS -Wno-deprecated-declarations
6 #include <objc/objc-runtime.h>
8 @interface Super : TestRoot @end
10 +(id)method:(int)__unused arg :(void(^)(void)) __unused arg2 {
20 struct objc_method_description *desc;
21 Method m = class_getClassMethod([Super class], sel_registerName("method::"));
24 testassert(method_getNumberOfArguments(m) == 4);
26 testassert(method_getSizeOfArguments(m) == 16);
29 arg = method_copyArgumentType(m, 0);
31 testassert(0 == strcmp(arg, "@"));
33 method_getArgumentType(m, 0, buf, 1+strlen(arg));
34 testassert(0 == strcmp(arg, buf));
35 testassert(buf[1+strlen(arg)] == 1);
37 method_getArgumentType(m, 0, buf, 2);
38 testassert(0 == strncmp(arg, buf, 2));
39 testassert(buf[2] == 1);
42 arg = method_copyArgumentType(m, 1);
44 testassert(0 == strcmp(arg, ":"));
46 method_getArgumentType(m, 1, buf, 1+strlen(arg));
47 testassert(0 == strcmp(arg, buf));
48 testassert(buf[1+strlen(arg)] == 1);
50 method_getArgumentType(m, 1, buf, 2);
51 testassert(0 == strncmp(arg, buf, 2));
52 testassert(buf[2] == 1);
55 arg = method_copyArgumentType(m, 2);
57 testassert(0 == strcmp(arg, "i"));
59 method_getArgumentType(m, 2, buf, 1+strlen(arg));
60 testassert(0 == strcmp(arg, buf));
61 testassert(buf[1+strlen(arg)] == 1);
63 method_getArgumentType(m, 2, buf, 2);
64 testassert(0 == strncmp(arg, buf, 2));
65 testassert(buf[2] == 1);
68 arg = method_copyArgumentType(m, 3);
70 testassert(0 == strcmp(arg, "@?"));
72 method_getArgumentType(m, 3, buf, 1+strlen(arg));
73 testassert(0 == strcmp(arg, buf));
74 testassert(buf[1+strlen(arg)] == 1);
76 method_getArgumentType(m, 3, buf, 2);
77 testassert(0 == strncmp(arg, buf, 2));
78 testassert(buf[2] == 1);
80 method_getArgumentType(m, 3, buf, 3);
81 testassert(0 == strncmp(arg, buf, 3));
82 testassert(buf[3] == 1);
85 arg = method_copyArgumentType(m, 4);
88 arg = method_copyArgumentType(m, -1);
92 method_getArgumentType(m, 4, buf, 127);
93 testassert(buf[0] == 0);
94 testassert(buf[1] == 0);
95 testassert(buf[127] == 1);
98 method_getArgumentType(m, -1, buf, 127);
99 testassert(buf[0] == 0);
100 testassert(buf[1] == 0);
101 testassert(buf[127] == 1);
103 arg = method_copyReturnType(m);
105 testassert(0 == strcmp(arg, "@"));
107 method_getReturnType(m, buf, 1+strlen(arg));
108 testassert(0 == strcmp(arg, buf));
109 testassert(buf[1+strlen(arg)] == 1);
111 method_getReturnType(m, buf, 2);
112 testassert(0 == strncmp(arg, buf, 2));
113 testassert(buf[2] == 1);
116 desc = method_getDescription(m);
118 testassert(desc->name == sel_registerName("method::"));
120 testassert(0 == strcmp(desc->types, "@28@0:8i16@?20"));
122 testassert(0 == strcmp(desc->types, "@16@0:4i8@?12"));
125 testassert(0 == method_getNumberOfArguments(NULL));
127 testassert(0 == method_getSizeOfArguments(NULL));
129 testassert(NULL == method_copyArgumentType(NULL, 10));
130 testassert(NULL == method_copyReturnType(NULL));
131 testassert(NULL == method_getDescription(NULL));
134 method_getArgumentType(NULL, 1, buf, 127);
135 testassert(buf[0] == 0);
136 testassert(buf[1] == 0);
137 testassert(buf[127] == 1);
140 method_getArgumentType(NULL, 1, buf, 0);
141 testassert(buf[0] == 1);
142 testassert(buf[1] == 1);
144 method_getArgumentType(m, 1, NULL, 128);
145 method_getArgumentType(m, 1, NULL, 0);
146 method_getArgumentType(NULL, 1, NULL, 128);
147 method_getArgumentType(NULL, 1, NULL, 0);
150 method_getReturnType(NULL, buf, 127);
151 testassert(buf[0] == 0);
152 testassert(buf[1] == 0);
153 testassert(buf[127] == 1);
156 method_getReturnType(NULL, buf, 0);
157 testassert(buf[0] == 1);
158 testassert(buf[1] == 1);
160 method_getReturnType(m, NULL, 128);
161 method_getReturnType(m, NULL, 0);
162 method_getReturnType(NULL, NULL, 128);
163 method_getReturnType(NULL, NULL, 0);