Native: correct ObjCExport test for forward declarations
The test relies on the fact that any name can be imported from a "magic" package like `objcnames.classes`. This was the case for K1, but likely won't be for K2: the compiler should allow importing only those names that are actually forward-declared in a cinterop library. This commit changes the test that way. In particular, moves it to a different task that has a cinterop dependency.
This commit is contained in:
committed by
Space Team
parent
445d44b79a
commit
86a29a7b07
@@ -0,0 +1,17 @@
|
||||
language=Objective-C
|
||||
---
|
||||
struct ForwardDeclaredStruct;
|
||||
@class ForwardDeclaredClass;
|
||||
@protocol ForwardDeclaredProtocol;
|
||||
|
||||
struct ForwardDeclaredStruct* sameStruct(struct ForwardDeclaredStruct* ptr) {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
ForwardDeclaredClass* sameClass(ForwardDeclaredClass* obj) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
id<ForwardDeclaredProtocol> sameProtocol(id<ForwardDeclaredProtocol> obj) {
|
||||
return obj;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import clib.*
|
||||
import cnames.structs.ForwardDeclaredStruct
|
||||
import objcnames.classes.ForwardDeclaredClass
|
||||
import objcnames.protocols.ForwardDeclaredProtocolProtocol
|
||||
import kotlinx.cinterop.CPointer
|
||||
|
||||
fun sameForwardDeclaredStruct(ptr: CPointer<ForwardDeclaredStruct>?): CPointer<ForwardDeclaredStruct>? = sameStruct(ptr)
|
||||
fun sameForwardDeclaredClass(obj: ForwardDeclaredClass?): ForwardDeclaredClass? = sameClass(obj)
|
||||
fun sameForwardDeclaredProtocol(obj: ForwardDeclaredProtocolProtocol?): ForwardDeclaredProtocolProtocol? = sameProtocol(obj)
|
||||
@@ -0,0 +1,25 @@
|
||||
import ForwardDeclarations
|
||||
|
||||
private func test1() throws {
|
||||
let ptr = UnsafeMutableRawPointer(bitPattern: 0x1234)
|
||||
try assertEquals(actual: LibKt.sameForwardDeclaredStruct(ptr: ptr), expected: ptr)
|
||||
|
||||
// We can't actually test this, because Swift can't import neither types nor functions due to
|
||||
// "interface/protocol '...' is incomplete":
|
||||
//
|
||||
// let classObj: ForwardDeclaredClass? = nil
|
||||
// try assertNil(LibKt.sameForwardDeclaredClass(obj: classObj))
|
||||
//
|
||||
// let protocolObj: ForwardDeclaredProtocol? = nil
|
||||
// try assertNil(LibKt.sameForwardDeclaredProtocol(obj: protocolObj))
|
||||
}
|
||||
|
||||
// -------- Execution of the test --------
|
||||
|
||||
class TestTests : SimpleTestProvider {
|
||||
override init() {
|
||||
super.init()
|
||||
|
||||
test("test1", test1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user