]> git.saurik.com Git - apple/objc4.git/blobdiff - test/protocol_cw.m
objc4-437.tar.gz
[apple/objc4.git] / test / protocol_cw.m
diff --git a/test/protocol_cw.m b/test/protocol_cw.m
new file mode 100644 (file)
index 0000000..a35ee7c
--- /dev/null
@@ -0,0 +1,36 @@
+#include "test.h"
+
+#if __OBJC2__
+
+int main()
+{
+    succeed(__FILE__);
+}
+
+#else
+
+// rdar://4951638
+
+#include <string.h>
+#include <objc/Protocol.h>
+
+char Protocol_name[] __attribute__((section("__OBJC,__class_names"))) = "Protocol";
+
+struct {
+    void *isa; 
+    char *protocol_name;
+    void *protocol_list;
+    void *instance_methods;
+    void *class_methods;
+} Foo_protocol __attribute__((section("__OBJC,__protocol"))) = { Protocol_name, "Foo", 0, 0, 0 };
+
+int main()
+{
+    Protocol *foo = objc_getProtocol("Foo");
+
+    testassert(foo == (Protocol *)&Foo_protocol);
+    testassert(0 == strcmp("Foo", [foo name]));
+    succeed(__FILE__);
+}
+
+#endif