Add trivial test for @OverrideInit
This commit is contained in:
committed by
SvyatoslavScherbina
parent
99e1ec6c9f
commit
d90d6cd47a
@@ -155,3 +155,8 @@ NSObject* createNSObject() {
|
|||||||
@interface TestVarargs (TestVarargsExtension)
|
@interface TestVarargs (TestVarargsExtension)
|
||||||
-(instancetype _Nonnull)initWithFormat:(NSString*)format, ...;
|
-(instancetype _Nonnull)initWithFormat:(NSString*)format, ...;
|
||||||
@end;
|
@end;
|
||||||
|
|
||||||
|
@interface TestOverrideInit : NSObject
|
||||||
|
-(instancetype)initWithValue:(int)value NS_DESIGNATED_INITIALIZER;
|
||||||
|
+(instancetype)createWithValue:(int)value;
|
||||||
|
@end;
|
||||||
@@ -22,6 +22,7 @@ fun run() {
|
|||||||
testBlocks()
|
testBlocks()
|
||||||
testCustomRetain()
|
testCustomRetain()
|
||||||
testVarargs()
|
testVarargs()
|
||||||
|
testOverrideInit()
|
||||||
|
|
||||||
assertEquals(2, ForwardDeclaredEnum.TWO.value)
|
assertEquals(2, ForwardDeclaredEnum.TWO.value)
|
||||||
|
|
||||||
@@ -299,6 +300,14 @@ fun testVarargs() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testOverrideInit() {
|
||||||
|
assertEquals(42, (TestOverrideInitImpl.createWithValue(42) as TestOverrideInitImpl).value)
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestOverrideInitImpl @OverrideInit constructor(val value: Int) : TestOverrideInit(value) {
|
||||||
|
companion object : TestOverrideInitMeta()
|
||||||
|
}
|
||||||
|
|
||||||
private class MyException : Throwable()
|
private class MyException : Throwable()
|
||||||
|
|
||||||
fun nsArrayOf(vararg elements: Any): NSArray = NSMutableArray().apply {
|
fun nsArrayOf(vararg elements: Any): NSArray = NSMutableArray().apply {
|
||||||
|
|||||||
@@ -145,3 +145,13 @@ static CustomRetainMethodsImpl* retainedCustomRetainMethodsImpl;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end;
|
@end;
|
||||||
|
|
||||||
|
@implementation TestOverrideInit
|
||||||
|
-(instancetype)initWithValue:(int)value {
|
||||||
|
return self = [super init];
|
||||||
|
}
|
||||||
|
|
||||||
|
+(instancetype)createWithValue:(int)value {
|
||||||
|
return [[self alloc] initWithValue:value];
|
||||||
|
}
|
||||||
|
@end;
|
||||||
Reference in New Issue
Block a user