]> git.saurik.com Git - apple/objc4.git/blob - test/swiftMetadataInitializerRealloc-dylib2.m
objc4-818.2.tar.gz
[apple/objc4.git] / test / swiftMetadataInitializerRealloc-dylib2.m
1 #include "test.h"
2 #include "swift-class-def.m"
3
4 @interface SwiftDylib1A: NSObject @end
5 @interface SwiftDylib1B: NSObject @end
6
7 @interface NSObject (DylibCategories)
8 - (char *)dylib1ACategoryInSameDylib;
9 - (char *)dylib1BCategoryInSameDylib;
10 - (char *)dylib1ACategoryInOtherDylib;
11 - (char *)dylib1BCategoryInOtherDylib;
12 - (char *)dylib1ACategoryInApp;
13 - (char *)dylib1BCategoryInApp;
14 + (void)testFromOtherDylib;
15 @end
16
17 @implementation SwiftDylib1A (Category)
18 - (const char *)dylib1ACategoryInOtherDylib { return "dylib1ACategoryInOtherDylib"; }
19 @end
20 @implementation SwiftDylib1B (Category)
21 - (const char *)dylib1BCategoryInOtherDylib { return "dylib1BCategoryInOtherDylib"; }
22 @end
23
24 SWIFT_STUB_CLASSREF(SwiftDylib1A);
25 SWIFT_STUB_CLASSREF(SwiftDylib1B);
26
27 Class objc_loadClassref(_Nullable Class * _Nonnull clsref);
28
29 @implementation SwiftDylib1A (Test)
30 + (void)testFromOtherDylib {
31 Class SwiftDylib1A = objc_loadClassref(&SwiftDylib1AClassref);
32 Class SwiftDylib1B = objc_loadClassref(&SwiftDylib1BClassref);
33 testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInSameDylib], "dylib1ACategoryInSameDylib") == 0);
34 testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInSameDylib], "dylib1BCategoryInSameDylib") == 0);
35 testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInApp], "dylib1ACategoryInApp") == 0);
36 testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInApp], "dylib1BCategoryInApp") == 0);
37 testassert(strcmp([[SwiftDylib1A new] dylib1ACategoryInOtherDylib], "dylib1ACategoryInOtherDylib") == 0);
38 testassert(strcmp([[SwiftDylib1B new] dylib1BCategoryInOtherDylib], "dylib1BCategoryInOtherDylib") == 0);
39 }
40 @end