[K/N] Add backend.native test for objcClassesIncludingCategories
This commit is contained in:
committed by
Space Team
parent
4ffb43c5bd
commit
3ade4fbedc
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
import objc_include_categories.*
|
||||
|
||||
class KotlinDerived : BaseClass() {
|
||||
override fun multiplyBy(value: Int): Float {
|
||||
return this.floatProperty * value * 100
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val base = BaseClass()
|
||||
println(base.floatProperty)
|
||||
val base2 = BaseClass(float = 3.14f)
|
||||
println(base2.floatProperty)
|
||||
println(base.multiplyBy(2))
|
||||
println()
|
||||
val derived = DerivedClass()
|
||||
println(derived.intProperty)
|
||||
val derived2 = DerivedClass(int = 6)
|
||||
println(derived2.intProperty)
|
||||
println(derived.multiplyBy(2))
|
||||
println()
|
||||
val kotlinDerived = KotlinDerived()
|
||||
println(kotlinDerived.floatProperty)
|
||||
println(kotlinDerived.multiplyBy(2))
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
3.0
|
||||
3.14
|
||||
6.0
|
||||
|
||||
3
|
||||
6
|
||||
6.0
|
||||
|
||||
3.0
|
||||
600.0
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
language = Objective-C
|
||||
headerFilter = **/objc_include_categories.h
|
||||
linkerOpts = -lobjcincludecategories
|
||||
objcClassesIncludingCategories = BaseClass DerivedClass
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#import <objc/NSObject.h>
|
||||
|
||||
@interface BaseClass : NSObject
|
||||
- (id) init;
|
||||
@property float floatProperty;
|
||||
@end;
|
||||
|
||||
@interface BaseClass(IncludeCategory)
|
||||
- (id)initWithFloat:(float)number;
|
||||
- (float) multiplyBy:(int)value;
|
||||
@end;
|
||||
|
||||
@interface DerivedClass : BaseClass
|
||||
- (id) init;
|
||||
@property int intProperty;
|
||||
@end;
|
||||
|
||||
@interface DerivedClass(IncludeCategory)
|
||||
- (id)initWithInt:(int)number;
|
||||
@end;
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#include "objc_include_categories.h"
|
||||
|
||||
@implementation BaseClass
|
||||
-(id) init {
|
||||
self.floatProperty = 3.0f;
|
||||
return self;
|
||||
}
|
||||
@end;
|
||||
|
||||
@implementation BaseClass(IncludeCategory)
|
||||
- (id)initWithFloat:(float)number {
|
||||
self.floatProperty = number;
|
||||
return self;
|
||||
}
|
||||
- (float) multiplyBy:(int)number {
|
||||
return self.floatProperty * 2;
|
||||
}
|
||||
@end;
|
||||
|
||||
@implementation DerivedClass
|
||||
-(id) init {
|
||||
self = [super init];
|
||||
self.intProperty = 3;
|
||||
return self;
|
||||
}
|
||||
@end;
|
||||
|
||||
@implementation DerivedClass(IncludeCategory)
|
||||
- (id)initWithInt:(int)number {
|
||||
self = [self init];
|
||||
self.intProperty = number;
|
||||
return self;
|
||||
}
|
||||
@end;
|
||||
Reference in New Issue
Block a user