K2/Native: simplify forward declarations test to make it work with K2
This commit is contained in:
committed by
Space Team
parent
46a85d9729
commit
d4f5d5297f
+2
-14
@@ -1,9 +1,7 @@
|
||||
// This test mostly checks frontend behaviour.
|
||||
|
||||
import cForwardDeclarations.*
|
||||
|
||||
// Note: there are no practical cases for this type, but it works in K1 so better to have a test for this.
|
||||
import cnames.structs.StructUndeclared
|
||||
import cnames.structs.StructDeclared
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlinx.cinterop.COpaque
|
||||
@@ -11,32 +9,22 @@ import kotlinx.cinterop.CStructVar
|
||||
import kotlinx.cinterop.ptr
|
||||
// The test should also check that these references can't be resolved, but the test infra doesn't support this yet:
|
||||
// import cForwardDeclarations.StructUndeclared
|
||||
// import cnames.structs.StructUndeclared // Supported in K1 though.
|
||||
|
||||
fun <T1 : T2, T2> checkSubtype2() {}
|
||||
fun <T1 : T2, T2 : T3, T3> checkSubtype3() {}
|
||||
fun <T1 : T2, T2 : T3, T3 : T4, T4> checkSubtype4() {}
|
||||
|
||||
// Here we rely on frontend reporting conflicting overloads if some of these types turn out to be the same.
|
||||
fun checkDifferentTypes(s: StructUndeclared?) = 0
|
||||
fun checkDifferentTypes(s: StructDeclared?) = 1
|
||||
fun checkDifferentTypes(s: StructDefined?) = 2
|
||||
|
||||
fun main() {
|
||||
// Checking it is the same type:
|
||||
checkSubtype3<StructUndeclared, cnames.structs.StructUndeclared, StructUndeclared>()
|
||||
checkSubtype2<StructUndeclared, COpaque>()
|
||||
|
||||
checkSubtype4<StructDeclared, cnames.structs.StructDeclared, cForwardDeclarations.StructDeclared, StructDeclared>()
|
||||
checkSubtype2<StructDeclared, COpaque>()
|
||||
|
||||
checkSubtype4<StructDefined, cnames.structs.StructDefined, cForwardDeclarations.StructDefined, StructDefined>()
|
||||
checkSubtype2<StructDefined, CStructVar>()
|
||||
|
||||
val undeclared: StructUndeclared? = null
|
||||
val declared: StructDeclared? = null
|
||||
val defined: StructDefined? = null
|
||||
|
||||
assertEquals(0, checkDifferentTypes(undeclared))
|
||||
assertEquals(1, checkDifferentTypes(declared))
|
||||
assertEquals(2, checkDifferentTypes(defined))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user