2 TEST_CFLAGS -Wno-deprecated-declarations
4 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')?
5 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')?
6 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')?
7 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')?
8 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\](\n.* note: expanded from macro 'testassert')?
9 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
10 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
11 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
12 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
13 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
14 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
15 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
16 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
17 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
18 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
19 .*methodArgs.m:\d+:\d+: warning: null passed to a callee that requires a non-null argument \[-Wnonnull\]
26 #include <objc/objc-runtime.h>
28 @interface Super : TestRoot @end
30 +(id)method:(int)__unused arg :(void(^)(void)) __unused arg2 {
40 struct objc_method_description *desc;
41 Method m = class_getClassMethod([Super class], sel_registerName("method::"));
44 testassert(method_getNumberOfArguments(m) == 4);
46 arg = method_copyArgumentType(m, 0);
48 testassert(0 == strcmp(arg, "@"));
50 method_getArgumentType(m, 0, buf, 1+strlen(arg));
51 testassert(0 == strcmp(arg, buf));
52 testassert(buf[1+strlen(arg)] == 1);
54 method_getArgumentType(m, 0, buf, 2);
55 testassert(0 == strncmp(arg, buf, 2));
56 testassert(buf[2] == 1);
59 arg = method_copyArgumentType(m, 1);
61 testassert(0 == strcmp(arg, ":"));
63 method_getArgumentType(m, 1, buf, 1+strlen(arg));
64 testassert(0 == strcmp(arg, buf));
65 testassert(buf[1+strlen(arg)] == 1);
67 method_getArgumentType(m, 1, buf, 2);
68 testassert(0 == strncmp(arg, buf, 2));
69 testassert(buf[2] == 1);
72 arg = method_copyArgumentType(m, 2);
74 testassert(0 == strcmp(arg, "i"));
76 method_getArgumentType(m, 2, buf, 1+strlen(arg));
77 testassert(0 == strcmp(arg, buf));
78 testassert(buf[1+strlen(arg)] == 1);
80 method_getArgumentType(m, 2, buf, 2);
81 testassert(0 == strncmp(arg, buf, 2));
82 testassert(buf[2] == 1);
85 arg = method_copyArgumentType(m, 3);
87 testassert(0 == strcmp(arg, "@?"));
89 method_getArgumentType(m, 3, buf, 1+strlen(arg));
90 testassert(0 == strcmp(arg, buf));
91 testassert(buf[1+strlen(arg)] == 1);
93 method_getArgumentType(m, 3, buf, 2);
94 testassert(0 == strncmp(arg, buf, 2));
95 testassert(buf[2] == 1);
97 method_getArgumentType(m, 3, buf, 3);
98 testassert(0 == strncmp(arg, buf, 3));
99 testassert(buf[3] == 1);
102 arg = method_copyArgumentType(m, 4);
105 arg = method_copyArgumentType(m, -1);
109 method_getArgumentType(m, 4, buf, 127);
110 testassert(buf[0] == 0);
111 testassert(buf[1] == 0);
112 testassert(buf[127] == 1);
115 method_getArgumentType(m, -1, buf, 127);
116 testassert(buf[0] == 0);
117 testassert(buf[1] == 0);
118 testassert(buf[127] == 1);
120 arg = method_copyReturnType(m);
122 testassert(0 == strcmp(arg, "@"));
124 method_getReturnType(m, buf, 1+strlen(arg));
125 testassert(0 == strcmp(arg, buf));
126 testassert(buf[1+strlen(arg)] == 1);
128 method_getReturnType(m, buf, 2);
129 testassert(0 == strncmp(arg, buf, 2));
130 testassert(buf[2] == 1);
133 desc = method_getDescription(m);
135 testassert(desc->name == sel_registerName("method::"));
137 testassert(0 == strcmp(desc->types, "@28@0:8i16@?20"));
139 testassert(0 == strcmp(desc->types, "@16@0:4i8@?12"));
142 testassert(0 == method_getNumberOfArguments(NULL));
143 testassert(NULL == method_copyArgumentType(NULL, 10));
144 testassert(NULL == method_copyReturnType(NULL));
145 testassert(NULL == method_getDescription(NULL));
148 method_getArgumentType(NULL, 1, buf, 127);
149 testassert(buf[0] == 0);
150 testassert(buf[1] == 0);
151 testassert(buf[127] == 1);
154 method_getArgumentType(NULL, 1, buf, 0);
155 testassert(buf[0] == 1);
156 testassert(buf[1] == 1);
158 method_getArgumentType(m, 1, NULL, 128);
159 method_getArgumentType(m, 1, NULL, 0);
160 method_getArgumentType(NULL, 1, NULL, 128);
161 method_getArgumentType(NULL, 1, NULL, 0);
164 method_getReturnType(NULL, buf, 127);
165 testassert(buf[0] == 0);
166 testassert(buf[1] == 0);
167 testassert(buf[127] == 1);
170 method_getReturnType(NULL, buf, 0);
171 testassert(buf[0] == 1);
172 testassert(buf[1] == 1);
174 method_getReturnType(m, NULL, 128);
175 method_getReturnType(m, NULL, 0);
176 method_getReturnType(NULL, NULL, 128);
177 method_getReturnType(NULL, NULL, 0);