diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index ccd6fc4d30d..07707d34688 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -6272,6 +6272,26 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index 7587526b232..bc0d04e92bb 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -6272,6 +6272,26 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 55dda958db7..21694596999 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -6272,6 +6272,26 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @Nested diff --git a/kotlin-native/backend.native/tests/interop/basics/1.kt b/compiler/testData/codegen/box/cinterop/basics/1.kt similarity index 56% rename from kotlin-native/backend.native/tests/interop/basics/1.kt rename to compiler/testData/codegen/box/cinterop/basics/1.kt index 1738fc1b39e..555f9e090e9 100644 --- a/kotlin-native/backend.native/tests/interop/basics/1.kt +++ b/compiler/testData/codegen/box/cinterop/basics/1.kt @@ -2,17 +2,26 @@ * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license * that can be found in the LICENSE file. */ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cstdlib.def +headers = stdlib.h + +// MODULE: main(cinterop) +// FILE: main.kt @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) import cstdlib.* import kotlinx.cinterop.* +import kotlin.test.* -fun main(args: Array) { - println(atoi("257")) +fun box(): String { + assertEquals(257, atoi("257")) val divResult = div(-5, 3) val (quot, rem) = divResult.useContents { Pair(quot, rem) } - println(quot) - println(rem) + assertEquals(-1, quot) + assertEquals(-2, rem) + return "OK" } diff --git a/compiler/testData/codegen/box/cinterop/basics/3.kt b/compiler/testData/codegen/box/cinterop/basics/3.kt new file mode 100644 index 00000000000..650aff9f5d6 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/basics/3.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cstdlib_3.def +headers = stdlib.h + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) + +import cstdlib_3.* +import kotlinx.cinterop.* +import kotlin.test.* + +fun box(): String { + val values = intArrayOf(14, 12, 9, 13, 8) + val count = values.size + + qsort(values.refTo(0), count.convert(), IntVar.size.convert(), staticCFunction { a, b -> + val aValue = a!!.reinterpret()[0] + val bValue = b!!.reinterpret()[0] + + (aValue - bValue) + }) + + assertEquals(8, values[0]) + assertEquals(9, values[1]) + assertEquals(12, values[2]) + assertEquals(13, values[3]) + assertEquals(14, values[4]) + + return "OK" +} diff --git a/kotlin-native/backend.native/tests/interop/basics/available_processors.kt b/compiler/testData/codegen/box/cinterop/basics/available_processors.kt similarity index 57% rename from kotlin-native/backend.native/tests/interop/basics/available_processors.kt rename to compiler/testData/codegen/box/cinterop/basics/available_processors.kt index 12e3a830582..c2deeb44764 100644 --- a/kotlin-native/backend.native/tests/interop/basics/available_processors.kt +++ b/compiler/testData/codegen/box/cinterop/basics/available_processors.kt @@ -2,26 +2,49 @@ * 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. */ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cstdlib_setenv.def +headers = stdlib.h +compilerOpts.mingw = -D ADD_WINDOWS_ENV_FUNCTIONS + +--- + +#ifdef ADD_WINDOWS_ENV_FUNCTIONS +static inline int setenv(const char *name, const char *value, int overwrite) +{ + int errcode = 0; + if (!overwrite) { + size_t envsize = 0; + errcode = getenv_s(&envsize, NULL, 0, name); + if(errcode || envsize) return errcode; + } + return _putenv_s(name, value); +} +static inline int unsetenv(const char *name) +{ + return _putenv_s(name, ""); +} +#endif + + +// MODULE: main(cinterop) +// FILE: main.kt @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class) import kotlin.native.* import kotlin.test.* -import cstdlib.* +import cstdlib_setenv.* import kotlinx.cinterop.* @OptIn(kotlin.ExperimentalStdlibApi::class) -fun main(args: Array) { - require(args.size == 1) { - "An expected anount of processors should be specified as program argument" - } - val x: Int = Platform.getAvailableProcessors() - println("Got available processors: $x") - assertTrue(x > 0) - if (!(Platform.osFamily == OsFamily.LINUX && (Platform.cpuArchitecture == CpuArchitecture.ARM32 || - Platform.cpuArchitecture == CpuArchitecture.ARM64))) { - assertEquals(args[0].trim().toInt(), x) - } +fun box(): String { + val platformProcessors: Int = Platform.getAvailableProcessors() + val jvmProcessors: Int = platformProcessors // Ideally, must be value of Runtime.getRuntime().availableProcessors() from testsystem + assertTrue(jvmProcessors > 0) + assertTrue(platformProcessors > 0) + assertEquals(jvmProcessors, platformProcessors) setenv("KOTLIN_NATIVE_AVAILABLE_PROCESSORS", "12345", 1) assertEquals(Platform.getAvailableProcessors(), 12345) @@ -39,5 +62,7 @@ fun main(args: Array) { setenv("KOTLIN_NATIVE_AVAILABLE_PROCESSORS", "123aaaa", 1) assertFailsWith { Platform.getAvailableProcessors() } unsetenv("KOTLIN_NATIVE_AVAILABLE_PROCESSORS") - assertEquals(Platform.getAvailableProcessors(), x) + assertEquals(Platform.getAvailableProcessors(), platformProcessors) + + return "OK" } diff --git a/compiler/testData/codegen/box/cinterop/basics/macros.kt b/compiler/testData/codegen/box/cinterop/basics/macros.kt new file mode 100644 index 00000000000..0d62a553184 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/basics/macros.kt @@ -0,0 +1,151 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cmacros.def +excludedMacros = EXCLUDED +--- +int* ptr_call() { + return (int*) 1; +} + +int int_call() { + return 42; +} + +void void_call() {} + +int arg_call(int x) { + return x; +} + +typedef struct { + int value +} struct_t; + +struct_t getStruct() { + return (struct_t){ 1 }; +} + +int global_var = 5; + +#define TOO_MANY_ERRORS x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x + +#define LEFT_BRACE { + +#define ZERO 0 +#define ONE 1 + +#define RIGHT_BRACE } + +#define MAX_LONG 9223372036854775807 +#define FOO_STRING "foo" +// This one should be ignored: +#define WIDE_FOO_STRING L"foo" +#define FOURTY_TWO 42 +#define SEVENTEEN ((long long) 17) +#define ONE_POINT_ZERO 1.0 +#define ONE_POINT_FIVE 1.5f + +#define LEFT_PAREN ( + +#define NULL_PTR ((void*)0) +#define VOID_PTR ((void*)1) +#define INT_PTR ((int*)1) +#define PTR_SUM (INT_PTR + 1) +#define PTR_SUM_EXPECTED (sizeof(int) + 1) + +#define RIGHT_PAREN ) + +enum { + INT_CALL = 1 // Should be replaced by macro below. +}; + +#define PTR_CALL ptr_call() +#define INT_CALL int_call() +#define CALL_SUM (int_call() + int_call()) +#define GLOBAL_VAR (global_var) + +// This one should be excluded: +#define EXCLUDED 42 + +// These ones should be ignored: +#define VOID_CALL (void_call()) +#define ARG_CALL(x) (arg_call(x)) +#define GET_STRUCT (getStruct()) +#define UNDECLARED (undeclared()) + +#define BAD1 bar +#define BAD2 5; +#define BAD3 { foo(); } + +void increment(int* counter); +#define increment(counter) { (*(counter))++; } + +#define DEFAULT_DOUBLE_NAN __builtin_nan("") +#define DEFAULT_FLOAT_NAN __builtin_nanf("") +#define OTHER_DOUBLE_NAN __builtin_nan("0x123456789ab") +#define OTHER_FLOAT_NAN __builtin_nanf("0x12345") + +// MODULE: main(cinterop) +// FILE: main.kt + +@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class) + +import kotlin.test.* +import cmacros.* +import kotlinx.cinterop.* + +fun box(): String { + assertEquals("foo", FOO_STRING) + assertEquals(0, ZERO) + assertEquals(1, ONE) + assertEquals(Long.MAX_VALUE, MAX_LONG) + assertEquals(42, FOURTY_TWO) + + val seventeen: Long = SEVENTEEN + assertEquals(17L, seventeen) + + val onePointFive: Float = ONE_POINT_FIVE + val onePointZero: Double = ONE_POINT_ZERO + + assertEquals(1.5f, onePointFive) + assertEquals(1.0, onePointZero) + + val nullPtr: COpaquePointer? = NULL_PTR + val voidPtr: COpaquePointer? = VOID_PTR + val intPtr: CPointer? = INT_PTR + val ptrSum: CPointer? = PTR_SUM + val ptrCall: CPointer? = PTR_CALL + + assertEquals(null, nullPtr) + assertEquals(1L, voidPtr.rawValue.toLong()) + assertEquals(1L, intPtr.rawValue.toLong()) + assertEquals(PTR_SUM_EXPECTED.toLong(), ptrSum.rawValue.toLong()) + assertEquals(1L, ptrCall.rawValue.toLong()) + + assertEquals(42, INT_CALL) + assertEquals(84, CALL_SUM) + assertEquals(5, GLOBAL_VAR) + + memScoped { + val counter = alloc() + counter.value = 42 + increment(counter.ptr) + assertEquals(43, counter.value) + } + + + val floatNanBase = Float.NaN.toRawBits() + assertEquals(floatNanBase, 0x7fc00000) + val doubleNanBase = Double.NaN.toRawBits() + assertEquals(doubleNanBase, 0x7ff8000000000000L) + assertEquals(floatNanBase, DEFAULT_FLOAT_NAN.toRawBits()) + assertEquals(doubleNanBase, DEFAULT_DOUBLE_NAN.toRawBits()) + assertEquals(floatNanBase, OTHER_FLOAT_NAN.toRawBits()) + assertEquals(doubleNanBase, OTHER_DOUBLE_NAN.toRawBits()) + + return "OK" +} diff --git a/compiler/testData/codegen/box/cinterop/basics/mangling.kt b/compiler/testData/codegen/box/cinterop/basics/mangling.kt new file mode 100644 index 00000000000..6fbbdb3afd7 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/basics/mangling.kt @@ -0,0 +1,24 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: mangling.def +--- + +// test mangling of special names + +enum _Companion {Companion, Any}; +enum _Companion companion = Companion; + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +import kotlinx.cinterop.* +import kotlin.test.* +import mangling.* + +fun box(): String { + companion = _Companion.`Companion$` + assertEquals(_Companion.`Companion$`, companion) + + return "OK" +} + diff --git a/compiler/testData/codegen/box/cinterop/basics/mangling2.kt b/compiler/testData/codegen/box/cinterop/basics/mangling2.kt new file mode 100644 index 00000000000..d7187a32381 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/basics/mangling2.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: mangling2.def +--- + +// test mangling of special names + +enum Companion {One, Two}; + + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +import kotlinx.cinterop.* +import kotlin.test.* +import mangling2.* + +fun box(): String { + val mangled = `Companion$`.Two + assertEquals(`Companion$`.Two, mangled) + return "OK" +} + diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords.kt b/compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt similarity index 55% rename from kotlin-native/backend.native/tests/interop/basics/mangling_keywords.kt rename to compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt index d9f9805a871..b10bf212730 100644 --- a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords.kt +++ b/compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt @@ -1,7 +1,34 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: mangling_keywords.def +--- +#define as "as" +#define class "class" +#define dynamic "dynamic" +#define false "false" +#define fun "fun" +#define in "in" +#define interface "interface" +#define is "is" +#define null "null" +#define object "object" +#define package "package" +#define super "super" +#define this "this" +#define throw "throw" +#define true "true" +#define try "try" +#define typealias "typealias" +#define val "val" +#define var "var" +#define when "when" +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) import kotlin.test.* import mangling_keywords.* -fun main() { +fun box(): String { // Check that all Kotlin keywords are imported and mangled. assertEquals("as", `as`) assertEquals("class", `class`) @@ -23,5 +50,6 @@ fun main() { assertEquals("val", `val`) assertEquals("var", `var`) assertEquals("when", `when`) + return "OK" } diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords2.kt b/compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt similarity index 63% rename from kotlin-native/backend.native/tests/interop/basics/mangling_keywords2.kt rename to compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt index a003d3af108..c39f01c6da7 100644 --- a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords2.kt +++ b/compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt @@ -1,8 +1,87 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: mangling_keywords2.def +--- +enum KotlinKeywordsEnum { + as, + class, + dynamic, + false, + fun, + in, + interface, + is, + null, + object, + package, + super, + this, + throw, + true, + try, + typealias, + val, + var, + when, +}; + +struct KotlinKeywordsStruct { + int as; + int class; + int dynamic; + int false; + int fun; + int in; + int interface; + int is; + int null; + int object; + int package; + int super; + int this; + int throw; + int true; + int try; + int typealias; + int val; + int var; + int when; + }; + +struct KotlinKeywordsStruct createKotlinKeywordsStruct() { + struct KotlinKeywordsStruct s = { + .as = 0, + .class = 0, + .dynamic = 0, + .false = 0, + .fun = 0, + .in = 0, + .interface = 0, + .is = 0, + .null = 0, + .object = 0, + .package = 0, + .super = 0, + .this = 0, + .throw = 0, + .true = 0, + .try = 0, + .typealias = 0, + .val = 0, + .var = 0, + .when = 0, + }; + return s; +} + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) import kotlin.test.* import mangling_keywords2.* import kotlinx.cinterop.useContents -fun main() { +fun box(): String { // Check that all Kotlin keywords are imported and mangled. createKotlinKeywordsStruct().useContents { assertEquals(0, `as`) @@ -47,4 +126,6 @@ fun main() { assertEquals(KotlinKeywordsEnum.`val`, KotlinKeywordsEnum.`val`) assertEquals(KotlinKeywordsEnum.`var`, KotlinKeywordsEnum.`var`) assertEquals(KotlinKeywordsEnum.`when`, KotlinKeywordsEnum.`when`) + + return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/cinterop/basics/structAnonym.kt b/compiler/testData/codegen/box/cinterop/basics/structAnonym.kt new file mode 100644 index 00000000000..fa77adbffc4 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/basics/structAnonym.kt @@ -0,0 +1,319 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: structAnonym.def +--- + +/* + * Test of return/send-by-value for aggregate type (struct or union) with anonymous inner struct or union member. + * Specific issues: alignment, packed, nested named and anon struct/union, other anon types (named field of anon struct type; anon bitfield) + */ + +#include + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winitializer-overrides" + +union _GLKVector3 +{ + struct { float x, y, z; }; + struct { float r, g, b; }; + struct { float s, t, p; }; + float v[3]; +}; + +static union _GLKVector3 get_GLKVector3() { + union _GLKVector3 ret = {{1, 2, 3}}; + return ret; +} + +static float hash_GLKVector3(union _GLKVector3 x) { + union _GLKVector3 ret = {{1, 2, 3}}; + return x.x + 2.0f * x.y + 4.0f * x.z; +} + +// trivial alignment: member is already aligned, but this implies implicit larger alignment of the root struct +struct StructAnonRecordMember_ImplicitAlignment { + int32_t a[4]; + struct { + int b __attribute__((aligned(16))); + }; +}; + +static struct StructAnonRecordMember_ImplicitAlignment retByValue_StructAnonRecordMember_ImplicitAlignment() { + struct StructAnonRecordMember_ImplicitAlignment t = { + .a = {1,2,3,4}, + .b = 42 + }; + return t; +} + +struct StructAnonRecordMember_ExplicitAlignment { + char a; + struct { + __attribute__((aligned(4))) + char x; + }; +}; + +static struct StructAnonRecordMember_ExplicitAlignment retByValue_StructAnonRecordMember_ExplicitAlignment() { + struct StructAnonRecordMember_ExplicitAlignment t = { + .a = 'a', + .x = 'x' + }; + return t; +} + +// Deep nesting +struct StructAnonRecordMember_Nested { + int x; + union { // implicitly aligned to 8 bytes due to int64, or 4 bytes at 32-bit arch + int a[2]; + struct { + int64_t b; + }; + }; + char z; + double y; +}; + +static struct StructAnonRecordMember_Nested retByValue_StructAnonRecordMember_Nested() { + struct StructAnonRecordMember_Nested c = { + .x = 37, + .b = 42, + .z = 'z', + .y = 3.14 + }; + return c; +} + +static int sendByValue_StructAnonRecordMember_Nested(struct StructAnonRecordMember_Nested c) { + return c.a[0] + 2 * c.a[1]; +} + +// Basic, 2 levels + +struct StructAnonRecordMember_Complicate { + char first; // __attribute__((aligned(16))); + union { + int a[2]; + union { char c1; int c2; }; + struct { char b1; int64_t b2; }; // implicit 64-bits alignment + }; + char second __attribute__((aligned(16))); + struct { + char x; + struct { int64_t b11, b12; } Y2; + int32_t f __attribute__((aligned(16))); + }; // __attribute__((aligned(16))); + char last; +}; + +#define INIT(T, x) struct T x = \ +{ \ + .first = 'a', \ + .b1 = 'b', \ + .b2 = 42, \ + .second = 's', \ + .last = 'z', \ + .f = 314, \ + .Y2 = {11, 12} \ +} + +static struct StructAnonRecordMember_Complicate retByValue_StructAnonRecordMember_Complicate() { + INIT(StructAnonRecordMember_Complicate, c); + return c; +} + +struct StructAnonRecordMember_Packed { + char first; + union { + int a[2]; + union { char c1; int c2; }; + struct { char b1; int64_t b2; }; + }; + char second; + struct { + char x; + struct { int64_t b11, b12; } Y2; + int32_t f; + } __attribute__((aligned(16))); + char last; +} __attribute__ ((packed)); + +static struct StructAnonRecordMember_Packed retByValue_StructAnonRecordMember_Packed() { + INIT(StructAnonRecordMember_Packed, c); + return c; +} + +// Nested struct may be packed too +#pragma pack(1) +struct StructAnonRecordMember_PragmaPacked { + char first; + union { + int a[2]; + union { char c1; int c2; }; + struct { char b1; int64_t b2; }; + }; + char second; + struct { + char x; + struct { int64_t b11, b12; } Y2; + int32_t f __attribute__((aligned(16))); // another kind of alignment + }; + char last; +} __attribute__ ((packed)); +#pragma pack() + +static struct StructAnonRecordMember_PragmaPacked retByValue_StructAnonRecordMember_PragmaPacked() { + INIT(StructAnonRecordMember_PragmaPacked, c); + return c; +} + +#pragma pack(2) +struct StructAnonRecordMember_Packed2 { + char first; + union { + int a[2]; + union { char c1; int c2; }; + struct { char b1; int64_t b2; }; + }; + char second; + struct { + char x; + struct { int64_t b11, b12; } Y2; + int32_t f; + } __attribute__((aligned(16))); + char last; +} __attribute__ ((packed)); +#pragma pack() + +static struct StructAnonRecordMember_Packed2 retByValue_StructAnonRecordMember_Packed2() { + INIT(StructAnonRecordMember_Packed2, c); + return c; +} + +#pragma clang diagnostic pop + +// MODULE: main(cinterop) +// FILE: main.kt + +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) + + +import kotlinx.cinterop.* +import kotlin.test.* +import structAnonym.* + + +fun test_GLKVector3() { + get_GLKVector3().useContents { + assertEquals(1.0f, x) + assertEquals(2.0f, g) + assertEquals(3.0f, p) + r = 0.1f + g = 0.2f + b = 0.3f + assertEquals(v[0], r) + assertEquals(v[1], g) + assertEquals(v[2], b) + + val ret = hash_GLKVector3(this.readValue()) + assertEquals(s + 2f * t + 4f * p , ret) + } +} + +fun test_StructAnonRecordMember_ImplicitAlignment() { + retByValue_StructAnonRecordMember_ImplicitAlignment() + .useContents { + assertEquals(1, a[0]) + assertEquals(4, a[3]) + assertEquals(42, b) + } +} + +fun test_StructAnonRecordMember_ExplicitAlignment() { + retByValue_StructAnonRecordMember_ExplicitAlignment() + .useContents { + assertEquals('a', a.toInt().toChar()) + assertEquals('x', x.toInt().toChar()) + } +} + +fun test_StructAnonRecordMember_Nested() { + retByValue_StructAnonRecordMember_Nested() + .useContents { + assertEquals(37, x) + assertEquals(42, b) + assertEquals('z', z.toInt().toChar()) + assertEquals(3.14, y) + + a[0] = 3 + a[1] = 5 + assertEquals(3 + 2*5, sendByValue_StructAnonRecordMember_Nested(this.readValue())) + } +} + +fun test_StructAnonym_Complicate() { + retByValue_StructAnonRecordMember_Complicate() + .useContents{ + assertEquals('a', first.toInt().toChar()) + assertEquals('s', second.toInt().toChar()) + assertEquals('z', last.toInt().toChar()) + assertEquals('b', b1.toInt().toChar()) + assertEquals(42L, b2) + assertEquals(314, f) + assertEquals(11L, Y2.b11) + } +} + +fun test_StructAnonym_Packed() { + retByValue_StructAnonRecordMember_Packed2() + .useContents{ + assertEquals('a', first.toInt().toChar()) + assertEquals('s', second.toInt().toChar()) + assertEquals('z', last.toInt().toChar()) + assertEquals('b', b1.toInt().toChar()) + assertEquals(42L, b2) + assertEquals(314, f) + assertEquals(11L, Y2.b11) + } +} + +fun test_StructAnonym_PragmaPacked() { + retByValue_StructAnonRecordMember_PragmaPacked() + .useContents{ + assertEquals('a', first.toInt().toChar()) + assertEquals('s', second.toInt().toChar()) + assertEquals('z', last.toInt().toChar()) + assertEquals('b', b1.toInt().toChar()) + assertEquals(42L, b2) + assertEquals(314, f) + assertEquals(11L, Y2.b11) + } +} + +fun test_StructAnonym_Packed2() { + retByValue_StructAnonRecordMember_Packed2() + .useContents{ + assertEquals('a', first.toInt().toChar()) + assertEquals('s', second.toInt().toChar()) + assertEquals('z', last.toInt().toChar()) + assertEquals('b', b1.toInt().toChar()) + assertEquals(42L, b2) + assertEquals(314, f) + assertEquals(11L, Y2.b11) + } +} + +fun box(): String { + test_GLKVector3() + test_StructAnonRecordMember_ImplicitAlignment() + test_StructAnonRecordMember_ExplicitAlignment() + test_StructAnonRecordMember_Nested() + test_StructAnonym_Complicate() + test_StructAnonym_Packed() + test_StructAnonym_PragmaPacked() + test_StructAnonym_Packed2() + + return "OK" +} diff --git a/kotlin-native/backend.native/tests/interop/basics/structs.kt b/compiler/testData/codegen/box/cinterop/basics/structs.kt similarity index 74% rename from kotlin-native/backend.native/tests/interop/basics/structs.kt rename to compiler/testData/codegen/box/cinterop/basics/structs.kt index ec56c26533c..1a09c89be77 100644 --- a/kotlin-native/backend.native/tests/interop/basics/structs.kt +++ b/compiler/testData/codegen/box/cinterop/basics/structs.kt @@ -1,10 +1,82 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cstructs.def +nonStrictEnums = NonStrict +--- +typedef struct { + int i; +} Trivial; + +enum E { + R, G, B +}; + +enum NonStrict { + N, S, K +}; + +struct Complex { + unsigned int ui; + Trivial t; + struct Complex* next; + enum E e; + enum NonStrict nonStrict; + int arr[2]; + _Bool b; +}; + +struct __attribute__((packed)) Packed { + int i : 1; + enum E e : 2; +}; + +struct Complex produceComplex() { + struct Complex complex = { + .ui = 128, + .t = {1}, + .next = 0, + .e = R, + .nonStrict = K, + .arr = {-51, -19}, + .b = 1 + }; + return complex; +}; + +struct WithFlexibleArray { + int size; + int data[]; +}; + +struct WithFlexibleArrayWithPadding { + int size; + char c; + long long data[]; +}; + +void fillArray(struct WithFlexibleArrayWithPadding *flex, int count) { + flex->size = count; + flex->c = '!'; + for (int i = 0; i < count; i++) { + flex->data[i] = (((long long)i) << 32) | (i * 100); + } +} + +struct WithZeroSizedArray { + int size; + int data[0]; +}; + +// MODULE: main(cinterop) +// FILE: main.kt + @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) import cstructs.* import kotlinx.cinterop.* import kotlin.test.* -fun main() { +fun box(): String { produceComplex().useContents { assertEquals(ui, 128u) ui = 333u @@ -107,7 +179,7 @@ fun main() { assertEquals((i.toLong() shl 32) or (i.toLong() * 100), flex.data[i]) } } - + return "OK" } fun checkEnumSubTyping(e: T) = memScoped { diff --git a/kotlin-native/backend.native/tests/interop/basics/ctypes.def b/compiler/testData/codegen/box/cinterop/basics/types.kt similarity index 54% rename from kotlin-native/backend.native/tests/interop/basics/ctypes.def rename to compiler/testData/codegen/box/cinterop/basics/types.kt index c6272ed75dc..811da68f1ab 100644 --- a/kotlin-native/backend.native/tests/interop/basics/ctypes.def +++ b/compiler/testData/codegen/box/cinterop/basics/types.kt @@ -1,3 +1,6 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: ctypes.def --- // KT-28065 @@ -38,8 +41,8 @@ static int vlaSum2DBothDimensions(int rows, int columns, int array[rows][columns int result = 0; for (int i = 0; i < rows; ++i) { for (int j = 0; j < columns; ++j) { - result += array[i][j]; - } + result += array[i][j]; + } } return result; } @@ -80,11 +83,50 @@ enum EnumCharBase : Char { }; static int sendEnum(enum EnumCharBase x) { - return (int)x + 2; + return (int)x + 2; } enum EnumExplicitChar : char { - EnumExplicitCharA = 'a', - EnumExplicitCharB = 'b', - EnumExplicitCharDup = 'a' + EnumExplicitCharA = 'a', + EnumExplicitCharB = 'b', + EnumExplicitCharDup = 'a' }; + +// MODULE: main(cinterop) +// FILE: main.kt + +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) + +import kotlinx.cinterop.* +import kotlin.native.* +import kotlin.test.* +import ctypes.* + +fun box(): String { + getStructWithConstFields().useContents { + assertEquals(111, x) + assertEquals(222, y) + } + + assertEquals(1u, ForwardDeclaredEnum.ONE.value) + + assertEquals(6, vlaSum(3, cValuesOf(1, 2, 3))) + assertEquals(10, vlaSum2D(2, cValuesOf(1, 2, 3, 4))) + assertEquals(21, vlaSum2DBothDimensions(2, 3, cValuesOf(1, 2, 3, 4, 5, 6))) + + // Not supported by clang: + // assertEquals(10, vlaSum2DForward(cValuesOf(1, 2, 3, 4), 2)) + + assertEquals(0u, StrictEnum1.StrictEnum1A.value) + assertEquals(1u, StrictEnum2.StrictEnum2B.value) + assertEquals(0u, NonStrictEnum1A) + assertEquals(1u, NonStrictEnum2B) + assertEquals(1, EnumCharBase.EnumCharBaseB.value) + assertEquals(3, sendEnum(EnumCharBase.EnumCharBaseB)) + assertEquals('a'.toByte(), EnumExplicitCharA) + assertEquals('b'.toByte(), EnumExplicitCharB) + assertEquals(EnumExplicitCharA, EnumExplicitCharDup) + + return "OK" +} + diff --git a/kotlin-native/backend.native/tests/interop/basics/union.kt b/compiler/testData/codegen/box/cinterop/basics/union.kt similarity index 74% rename from kotlin-native/backend.native/tests/interop/basics/union.kt rename to compiler/testData/codegen/box/cinterop/basics/union.kt index b6633800aa5..43700d2c7b5 100644 --- a/kotlin-native/backend.native/tests/interop/basics/union.kt +++ b/compiler/testData/codegen/box/cinterop/basics/union.kt @@ -1,3 +1,27 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cunion.def +--- +typedef union { + short s; + long long ll; +} BasicUnion; + +typedef struct { + union { + int i; + float f; + } as; +} StructWithUnion; + +typedef union { + unsigned int i : 31; + unsigned char b : 1; +} Packed; + +// MODULE: main(cinterop) +// FILE: main.kt + @file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class) import cunion.* @@ -5,7 +29,7 @@ import kotlinx.cinterop.* import kotlin.native.* import kotlin.test.* -fun main() { +fun box(): String { memScoped { val basicUnion = alloc() for (value in Short.MIN_VALUE..Short.MAX_VALUE) { @@ -35,4 +59,5 @@ fun main() { union.i = 0u assertEquals(0u, union.b) } + return "OK" } diff --git a/kotlin-native/backend.native/tests/interop/basics/cunsupported.def b/compiler/testData/codegen/box/cinterop/basics/unsupported.kt similarity index 64% rename from kotlin-native/backend.native/tests/interop/basics/cunsupported.def rename to compiler/testData/codegen/box/cinterop/basics/unsupported.kt index e4c19142291..bb42351d158 100644 --- a/kotlin-native/backend.native/tests/interop/basics/cunsupported.def +++ b/compiler/testData/codegen/box/cinterop/basics/unsupported.kt @@ -1,3 +1,10 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cunsupported.def compilerOpts = -mno-xsave --- @@ -25,3 +32,16 @@ ALL_ATTRS1 void macroAttr5() {} #define ALL_ATTRS2 __attribute__((always_inline, __target__("xsave"))) ALL_ATTRS2 void macroAttr6() {} + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +import kotlin.test.* +import cunsupported.* + +fun box(): String { + noAttr() + noTargetAttr() + + return "OK" +} diff --git a/compiler/testData/codegen/box/cinterop/basics/values.kt b/compiler/testData/codegen/box/cinterop/basics/values.kt new file mode 100644 index 00000000000..c20dd1bc0d0 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/basics/values.kt @@ -0,0 +1,30 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cvalues.def +--- +_Bool isNullString(const char* str) { + return str == (const char*)0; +} + +typedef const short* LPCWSTR; + +_Bool isNullWString(LPCWSTR str) { + return str == (LPCWSTR)0; +} + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) + +import kotlinx.cinterop.* +import kotlin.test.* +import cvalues.* + +fun box(): String { + assertTrue(isNullString(null)) + assertTrue(isNullWString(null)) + assertFalse(isNullString("a")) + assertFalse(isNullWString("b")) + + return "OK" +} diff --git a/kotlin-native/backend.native/tests/interop/basics/vectors.kt b/compiler/testData/codegen/box/cinterop/basics/vectors.kt similarity index 51% rename from kotlin-native/backend.native/tests/interop/basics/vectors.kt rename to compiler/testData/codegen/box/cinterop/basics/vectors.kt index 09ab8732cf5..0f8165175d5 100644 --- a/kotlin-native/backend.native/tests/interop/basics/vectors.kt +++ b/compiler/testData/codegen/box/cinterop/basics/vectors.kt @@ -1,3 +1,37 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cvectors.def +--- +typedef float __attribute__ ((__vector_size__ (16))) KVector4f; +typedef int __attribute__ ((__vector_size__ (16))) KVector4i32; + +struct Complex { + unsigned int ui; + KVector4f vec4f; + struct Complex* next; + int arr[2]; +}; + +struct Complex produceComplexVector() { + struct Complex complex = { + .ui = 128, + .vec4f = {1.0, 1.0, 1.0, 1.0}, + .next = 0, + .arr = {-51, -19} + }; + return complex; +}; + +static float sendV4F(KVector4f v) { + return v[0] + 2 * v[1] + 4 * v[2] + 8 * v[3]; +} + +static int sendV4I(KVector4i32 v) { + return v[0] + 2 * v[1] + 4 * v[2] + 8 * v[3]; +} + +// MODULE: main(cinterop) +// FILE: main.kt @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalNativeApi::class) import kotlinx.cinterop.* @@ -6,8 +40,8 @@ import kotlin.native.* import kotlin.test.* import cvectors.* -fun main() { - produceComplex().useContents { +fun box(): String { + produceComplexVector().useContents { assertEquals(vec4f, vectorOf(1.0f, 1.0f, 1.0f, 1.0f)) vec4f = vectorOf(0.0f, 0.0f, 0.0f, 0.0f) assertEquals(vec4f, vectorOf(0.0f, 0.0f, 0.0f, 0.0f)) @@ -25,4 +59,6 @@ fun main() { } assertEquals(vector.value, vectorOf(1, 2, 3, 4)) } + + return "OK" } diff --git a/compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt b/compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt new file mode 100644 index 00000000000..853c4461740 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt @@ -0,0 +1,37 @@ +// TARGET_BACKEND: NATIVE +// MODULE: cinterop +// FILE: cCallback.def +language = C +--- +extern char* sb; +void runAndCatch(void(*f)(void)); + +// FILE: cCallback.cpp +#include + +char* sb = nullptr; +extern "C" void runAndCatch(void(*f)(void)) { + try { + f(); + } catch (...) { + sb = "OK"; + } +} + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) + +import kotlinx.cinterop.staticCFunction +import kotlinx.cinterop.toKString +import cCallback.runAndCatch +import cCallback.sb + +fun throwingCallback() { + throw IllegalStateException("Kotlin Exception!") +} + +fun box(): String { + runAndCatch(staticCFunction(::throwingCallback)) + return sb?.toKString() ?: "FAIL" +} diff --git a/compiler/testData/codegen/box/cinterop/kt63048.kt b/compiler/testData/codegen/box/cinterop/kt63048.kt index d126879e278..13bf9283e8d 100644 --- a/compiler/testData/codegen/box/cinterop/kt63048.kt +++ b/compiler/testData/codegen/box/cinterop/kt63048.kt @@ -1,5 +1,5 @@ // TARGET_BACKEND: NATIVE -// MODULE: cinterop +// MODULE: cinterop_kt63048 // FILE: kt63048.def language = Objective-C headers = kt63048.h @@ -23,7 +23,7 @@ headers = kt63048.h @end -// MODULE: main(cinterop) +// MODULE: main(cinterop_kt63048) // FILE: main.kt @file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class, kotlin.experimental.ExperimentalObjCName::class) diff --git a/compiler/testData/codegen/box/cinterop/kt63049.kt b/compiler/testData/codegen/box/cinterop/kt63049.kt index ae17eb40189..df92d0c0ff5 100644 --- a/compiler/testData/codegen/box/cinterop/kt63049.kt +++ b/compiler/testData/codegen/box/cinterop/kt63049.kt @@ -3,8 +3,16 @@ // FILE: kt63049.def depends = Foundation language = Objective-C ---- -@interface WithClassProperty +headers = kt63049.h + +// FILE: kt63049.h +#import "Foundation/NSObject.h" +@interface KT63049 : NSObject +@end + +// FILE: kt63049.m +#import "kt63049.h" +@implementation KT63049 : NSObject @end // MODULE: main(cinterop) @@ -14,8 +22,8 @@ language = Objective-C import kt63049.* import kotlin.test.assertEquals -class Impl : WithClassProperty() { - companion object : WithClassPropertyMeta() { +class Impl : KT63049() { + companion object : KT63049Meta() { fun stringProperty(): String? = "OK" } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java index 553ae3fa4f2..49f1536bb80 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java @@ -6272,6 +6272,26 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index e867741f0ce..a7bfb888a76 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -6038,6 +6038,26 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 3475620b151..9cc1aeebb68 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -6272,6 +6272,26 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 04451653140..cabaf71b682 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -6272,6 +6272,26 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 28901c22156..86ab8fd4f55 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -5483,6 +5483,32 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Basics extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Exceptions extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } } @TestMetadata("compiler/testData/codegen/box/classLiteral") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index f31159868c6..9801dcd2b50 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -4610,6 +4610,26 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java index 993ad5e93d2..88ad2d45cc1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java @@ -4610,6 +4610,26 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 11de0a41393..d51346f9474 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -4610,6 +4610,26 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 07702f1d6fa..3f7e1ca9ca3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -4610,6 +4610,26 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } } @Nested diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index d094e231aa4..f4de414de06 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -1069,10 +1069,6 @@ createInterop("sysstat") { it.defFile f } -createInterop("cstdlib") { - it.defFile 'interop/basics/cstdlib.def' -} - createInterop("cstdio") { it.defFile 'interop/basics/cstdio.def' } @@ -1081,54 +1077,6 @@ createInterop("sockets") { it.defFile 'interop/basics/sockets.def' } -createInterop("cmacros") { - it.defFile 'interop/basics/cmacros.def' -} - -createInterop("cunsupported") { - it.defFile 'interop/basics/cunsupported.def' -} - -createInterop("ctypes") { - it.defFile 'interop/basics/ctypes.def' -} - -createInterop("structAnonym") { - it.defFile 'interop/basics/structAnonym.def' -} - -createInterop("cvalues") { - it.defFile 'interop/basics/cvalues.def' -} - -createInterop("cvectors") { - it.defFile 'interop/basics/cvectors.def' -} - -createInterop("cstructs") { - it.defFile 'interop/basics/cstructs.def' -} - -createInterop("cmangling") { - it.defFile 'interop/basics/mangling.def' -} - -createInterop("cmangling2") { - it.defFile 'interop/basics/mangling2.def' -} - -createInterop("cmangling_keywords") { - it.defFile 'interop/basics/mangling_keywords.def' -} - -createInterop("cmangling_keywords2") { - it.defFile 'interop/basics/mangling_keywords2.def' -} - -createInterop("cunion") { - it.defFile 'interop/basics/cunion.def' -} - createInterop("concurrentTerminate") { it.defFile 'interop/concurrentTerminate/concurrentTerminate.def' it.headers "$projectDir/interop/concurrentTerminate/async.h" @@ -1368,11 +1316,6 @@ createInterop("exceptions_throwThroughBridge") { it.extraOpts "-Xcompile-source", "$projectDir/interop/exceptions/throwThroughBridgeInterop.cpp" } -createInterop("exceptions_cCallback") { - it.defFile "interop/exceptions/cCallback.def" - it.extraOpts "-Xcompile-source", "$projectDir/interop/exceptions/cCallback.cpp" -} - /** * Creates a task for the interop test. Configures runner and adds library and test build tasks. */ @@ -1439,12 +1382,6 @@ standaloneTest("interop_objc_allocException") { UtilsKt.dependsOnPlatformLibs(it) } -interopTest("interop_available_processors") { - source = 'interop/basics/available_processors.kt' - arguments = [Runtime.getRuntime().availableProcessors().toString()] - interop = 'cstdlib' -} - interopTest("interop0") { disabled = (project.testTarget == 'linux_arm64') useGoldenData = true @@ -1452,24 +1389,12 @@ interopTest("interop0") { interop = 'sysstat' } -interopTest("interop1") { - useGoldenData = true - source = "interop/basics/1.kt" - interop = 'cstdlib' -} - interopTest("interop2") { useGoldenData = true source = "interop/basics/2.kt" interop = 'cstdio' } -interopTest("interop3") { - useGoldenData = true - source = "interop/basics/3.kt" - interop = 'cstdlib' -} - interopTest("interop4") { useGoldenData = true source = "interop/basics/4.kt" @@ -1482,51 +1407,6 @@ standaloneTest("interop5") { UtilsKt.dependsOnPlatformLibs(it) } -interopTest("interop_macros") { - source = "interop/basics/macros.kt" - interop = 'cmacros' -} - -interopTest("interop_unsupported") { - source = "interop/basics/unsupported.kt" - interop = 'cunsupported' -} - -interopTest("interop_types") { - source = "interop/basics/types.kt" - interop = 'ctypes' -} - -interopTest("interop_structAnonym") { - source = "interop/basics/structAnonym.kt" - interop = 'structAnonym' -} - -interopTest("interop_vectors") { - source = "interop/basics/vectors.kt" - interop = 'cvectors' -} - -interopTest("interop_mangling") { - source = "interop/basics/mangling.kt" - interop = 'cmangling' -} - -interopTest("interop_mangling2") { - source = "interop/basics/mangling2.kt" - interop = 'cmangling2' -} - -interopTest("interop_mangling_keywords") { - source = "interop/basics/mangling_keywords.kt" - interop = 'cmangling_keywords' -} - -interopTest("interop_mangling_keywords2") { - source = "interop/basics/mangling_keywords2.kt" - interop = 'cmangling_keywords2' -} - interopTest("interop_concurrentTerminate") { source = "interop/concurrentTerminate/main.kt" interop = 'concurrentTerminate' @@ -1539,16 +1419,6 @@ interopTest("interop_embedStaticLibraries") { interop = 'embedStaticLibraries' } -interopTest("interop_values") { - source = "interop/basics/values.kt" - interop = 'cvalues' -} - -interopTest("interop_structs") { - source = "interop/basics/structs.kt" - interop = 'cstructs' -} - interopTest("interop_threadStates") { source = "interop/threadStates/threadStates.kt" flags = ['-opt-in=kotlin.native.internal.InternalForKotlinNative'] @@ -1586,11 +1456,6 @@ interopTest("interop_withSpaces") { } } -interopTest("interop_union") { - interop = 'cunion' - source = "interop/basics/union.kt" -} - // TODO: This test should be run with caches on. interopTest("interop_kt51925") { interop = 'kt51925' @@ -2310,12 +2175,6 @@ dynamicTest("interop_kotlin_exception_hook") { outputChecker = { s -> s.contains("OK. Kotlin unhandled exception hook") } } -interopTest("interop_exceptions_cCallback") { - source = "interop/exceptions/cCallback.kt" - outputChecker = { s -> s.contains("CATCH IN C++") } - interop = "exceptions_cCallback" -} - standaloneTest("library_ir_provider_mismatch") { enabled = !isAggressiveGC // No need to test with different GC schedulers diff --git a/kotlin-native/backend.native/tests/interop/basics/1.out b/kotlin-native/backend.native/tests/interop/basics/1.out deleted file mode 100644 index 00b1ec5889f..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/1.out +++ /dev/null @@ -1,3 +0,0 @@ -257 --1 --2 diff --git a/kotlin-native/backend.native/tests/interop/basics/3.kt b/kotlin-native/backend.native/tests/interop/basics/3.kt deleted file mode 100644 index 3d38cf2db9d..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/3.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ -@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) - -import kotlinx.cinterop.* - -fun main(args: Array) { - val values = intArrayOf(14, 12, 9, 13, 8) - val count = values.size - - cstdlib.qsort(values.refTo(0), count.convert(), IntVar.size.convert(), staticCFunction { a, b -> - val aValue = a!!.reinterpret()[0] - val bValue = b!!.reinterpret()[0] - - (aValue - bValue) - }) - - for (i in 0..count - 1) { - print(values[i]) - print(" ") - } - println() -} diff --git a/kotlin-native/backend.native/tests/interop/basics/3.out b/kotlin-native/backend.native/tests/interop/basics/3.out deleted file mode 100644 index 9110b8474f8..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/3.out +++ /dev/null @@ -1 +0,0 @@ -8 9 12 13 14 diff --git a/kotlin-native/backend.native/tests/interop/basics/cmacros.def b/kotlin-native/backend.native/tests/interop/basics/cmacros.def deleted file mode 100644 index c197e8f6688..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/cmacros.def +++ /dev/null @@ -1,83 +0,0 @@ -excludedMacros = EXCLUDED ---- -int* ptr_call() { - return (int*) 1; -} - -int int_call() { - return 42; -} - -void void_call() {} - -int arg_call(int x) { - return x; -} - -typedef struct { - int value -} struct_t; - -struct_t getStruct() { - return (struct_t){ 1 }; -} - -int global_var = 5; - -#define TOO_MANY_ERRORS x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x - -#define LEFT_BRACE { - -#define ZERO 0 -#define ONE 1 - -#define RIGHT_BRACE } - -#define MAX_LONG 9223372036854775807 -#define FOO_STRING "foo" -// This one should be ignored: -#define WIDE_FOO_STRING L"foo" -#define FOURTY_TWO 42 -#define SEVENTEEN ((long long) 17) -#define ONE_POINT_ZERO 1.0 -#define ONE_POINT_FIVE 1.5f - -#define LEFT_PAREN ( - -#define NULL_PTR ((void*)0) -#define VOID_PTR ((void*)1) -#define INT_PTR ((int*)1) -#define PTR_SUM (INT_PTR + 1) -#define PTR_SUM_EXPECTED (sizeof(int) + 1) - -#define RIGHT_PAREN ) - -enum { - INT_CALL = 1 // Should be replaced by macro below. -}; - -#define PTR_CALL ptr_call() -#define INT_CALL int_call() -#define CALL_SUM (int_call() + int_call()) -#define GLOBAL_VAR (global_var) - -// This one should be excluded: -#define EXCLUDED 42 - -// These ones should be ignored: -#define VOID_CALL (void_call()) -#define ARG_CALL(x) (arg_call(x)) -#define GET_STRUCT (getStruct()) -#define UNDECLARED (undeclared()) - -#define BAD1 bar -#define BAD2 5; -#define BAD3 { foo(); } - -void increment(int* counter); -#define increment(counter) { (*(counter))++; } - -#define DEFAULT_DOUBLE_NAN __builtin_nan("") -#define DEFAULT_FLOAT_NAN __builtin_nanf("") -#define OTHER_DOUBLE_NAN __builtin_nan("0x123456789ab") -#define OTHER_FLOAT_NAN __builtin_nanf("0x12345") diff --git a/kotlin-native/backend.native/tests/interop/basics/cstdlib.def b/kotlin-native/backend.native/tests/interop/basics/cstdlib.def deleted file mode 100644 index 6bff822298e..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/cstdlib.def +++ /dev/null @@ -1,21 +0,0 @@ -headers = stdlib.h -compilerOpts.mingw = -D ADD_WINDOWS_ENV_FUNCTIONS - ---- - -#ifdef ADD_WINDOWS_ENV_FUNCTIONS -static inline int setenv(const char *name, const char *value, int overwrite) -{ - int errcode = 0; - if (!overwrite) { - size_t envsize = 0; - errcode = getenv_s(&envsize, NULL, 0, name); - if(errcode || envsize) return errcode; - } - return _putenv_s(name, value); -} -static inline int unsetenv(const char *name) -{ - return _putenv_s(name, ""); -} -#endif diff --git a/kotlin-native/backend.native/tests/interop/basics/cstructs.def b/kotlin-native/backend.native/tests/interop/basics/cstructs.def deleted file mode 100644 index e70c8458b4c..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/cstructs.def +++ /dev/null @@ -1,65 +0,0 @@ -nonStrictEnums = NonStrict ---- -typedef struct { - int i; -} Trivial; - -enum E { - R, G, B -}; - -enum NonStrict { - N, S, K -}; - -struct Complex { - unsigned int ui; - Trivial t; - struct Complex* next; - enum E e; - enum NonStrict nonStrict; - int arr[2]; - _Bool b; -}; - -struct __attribute__((packed)) Packed { - int i : 1; - enum E e : 2; -}; - -struct Complex produceComplex() { - struct Complex complex = { - .ui = 128, - .t = {1}, - .next = 0, - .e = R, - .nonStrict = K, - .arr = {-51, -19}, - .b = 1 - }; - return complex; -}; - -struct WithFlexibleArray { - int size; - int data[]; -}; - -struct WithFlexibleArrayWithPadding { - int size; - char c; - long long data[]; -}; - -void fillArray(struct WithFlexibleArrayWithPadding *flex, int count) { - flex->size = count; - flex->c = '!'; - for (int i = 0; i < count; i++) { - flex->data[i] = (((long long)i) << 32) | (i * 100); - } -} - -struct WithZeroSizedArray { - int size; - int data[0]; -}; \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/basics/cunion.def b/kotlin-native/backend.native/tests/interop/basics/cunion.def deleted file mode 100644 index 58407a348cd..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/cunion.def +++ /dev/null @@ -1,17 +0,0 @@ ---- -typedef union { - short s; - long long ll; -} BasicUnion; - -typedef struct { - union { - int i; - float f; - } as; -} StructWithUnion; - -typedef union { - unsigned int i : 31; - unsigned char b : 1; -} Packed; \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/basics/cvalues.def b/kotlin-native/backend.native/tests/interop/basics/cvalues.def deleted file mode 100644 index 77e0cbac565..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/cvalues.def +++ /dev/null @@ -1,10 +0,0 @@ ---- -_Bool isNullString(const char* str) { - return str == (const char*)0; -} - -typedef const short* LPCWSTR; - -_Bool isNullWString(LPCWSTR str) { - return str == (LPCWSTR)0; -} diff --git a/kotlin-native/backend.native/tests/interop/basics/cvectors.def b/kotlin-native/backend.native/tests/interop/basics/cvectors.def deleted file mode 100644 index 9c303835d44..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/cvectors.def +++ /dev/null @@ -1,28 +0,0 @@ ---- -typedef float __attribute__ ((__vector_size__ (16))) KVector4f; -typedef int __attribute__ ((__vector_size__ (16))) KVector4i32; - -struct Complex { - unsigned int ui; - KVector4f vec4f; - struct Complex* next; - int arr[2]; -}; - -struct Complex produceComplex() { - struct Complex complex = { - .ui = 128, - .vec4f = {1.0, 1.0, 1.0, 1.0}, - .next = 0, - .arr = {-51, -19} - }; - return complex; -}; - -static float sendV4F(KVector4f v) { - return v[0] + 2 * v[1] + 4 * v[2] + 8 * v[3]; -} - -static int sendV4I(KVector4i32 v) { - return v[0] + 2 * v[1] + 4 * v[2] + 8 * v[3]; -} diff --git a/kotlin-native/backend.native/tests/interop/basics/macros.kt b/kotlin-native/backend.native/tests/interop/basics/macros.kt deleted file mode 100644 index b7947131531..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/macros.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ -@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, kotlinx.cinterop.ExperimentalForeignApi::class) - -import kotlin.test.* -import cmacros.* -import kotlinx.cinterop.* - -fun main(args: Array) { - assertEquals("foo", FOO_STRING) - assertEquals(0, ZERO) - assertEquals(1, ONE) - assertEquals(Long.MAX_VALUE, MAX_LONG) - assertEquals(42, FOURTY_TWO) - - val seventeen: Long = SEVENTEEN - assertEquals(17L, seventeen) - - val onePointFive: Float = ONE_POINT_FIVE - val onePointZero: Double = ONE_POINT_ZERO - - assertEquals(1.5f, onePointFive) - assertEquals(1.0, onePointZero) - - val nullPtr: COpaquePointer? = NULL_PTR - val voidPtr: COpaquePointer? = VOID_PTR - val intPtr: CPointer? = INT_PTR - val ptrSum: CPointer? = PTR_SUM - val ptrCall: CPointer? = PTR_CALL - - assertEquals(null, nullPtr) - assertEquals(1L, voidPtr.rawValue.toLong()) - assertEquals(1L, intPtr.rawValue.toLong()) - assertEquals(PTR_SUM_EXPECTED.toLong(), ptrSum.rawValue.toLong()) - assertEquals(1L, ptrCall.rawValue.toLong()) - - assertEquals(42, INT_CALL) - assertEquals(84, CALL_SUM) - assertEquals(5, GLOBAL_VAR) - - memScoped { - val counter = alloc() - counter.value = 42 - increment(counter.ptr) - assertEquals(43, counter.value) - } - - - /** - * Mips processors are using different notation for quite/signaling nans. - * In particular, same clang intrinsic __builtin_nan() return other bitpatterns on mips, - * to avoid values, which would be singaling on MIPS. So, tested values are incorrect in that case. - */ - if (Platform.cpuArchitecture != CpuArchitecture.MIPS32 && Platform.cpuArchitecture != CpuArchitecture.MIPSEL32) { - val floatNanBase = Float.NaN.toRawBits() - assertEquals(floatNanBase, 0x7fc00000) - val doubleNanBase = Double.NaN.toRawBits() - assertEquals(doubleNanBase, 0x7ff8000000000000L) - assertEquals(floatNanBase, DEFAULT_FLOAT_NAN.toRawBits()) - assertEquals(doubleNanBase, DEFAULT_DOUBLE_NAN.toRawBits()) - assertEquals(floatNanBase, OTHER_FLOAT_NAN.toRawBits()) - assertEquals(doubleNanBase, OTHER_DOUBLE_NAN.toRawBits()) - } -} diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling.def b/kotlin-native/backend.native/tests/interop/basics/mangling.def deleted file mode 100644 index 99fe71b2fa1..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/mangling.def +++ /dev/null @@ -1,6 +0,0 @@ ---- - -// test mangling of special names - -enum _Companion {Companion, Any}; -enum _Companion companion = Companion; diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling.kt b/kotlin-native/backend.native/tests/interop/basics/mangling.kt deleted file mode 100644 index 3bf58ae1b84..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/mangling.kt +++ /dev/null @@ -1,9 +0,0 @@ -import kotlinx.cinterop.* -import kotlin.test.* -import mangling.* - -fun main() { - companion = _Companion.`Companion$` - assertEquals(_Companion.`Companion$`, companion) -} - diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling2.def b/kotlin-native/backend.native/tests/interop/basics/mangling2.def deleted file mode 100644 index 60dec063505..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/mangling2.def +++ /dev/null @@ -1,6 +0,0 @@ ---- - -// test mangling of special names - -enum Companion {One, Two}; - diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling2.kt b/kotlin-native/backend.native/tests/interop/basics/mangling2.kt deleted file mode 100644 index 3179e430f5e..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/mangling2.kt +++ /dev/null @@ -1,9 +0,0 @@ -import kotlinx.cinterop.* -import kotlin.test.* -import mangling2.* - -fun main() { - val mangled = `Companion$`.Two - assertEquals(`Companion$`.Two, mangled) -} - diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords.def b/kotlin-native/backend.native/tests/interop/basics/mangling_keywords.def deleted file mode 100644 index 942ac988bb4..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords.def +++ /dev/null @@ -1,21 +0,0 @@ ---- -#define as "as" -#define class "class" -#define dynamic "dynamic" -#define false "false" -#define fun "fun" -#define in "in" -#define interface "interface" -#define is "is" -#define null "null" -#define object "object" -#define package "package" -#define super "super" -#define this "this" -#define throw "throw" -#define true "true" -#define try "try" -#define typealias "typealias" -#define val "val" -#define var "var" -#define when "when" \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords2.def b/kotlin-native/backend.native/tests/interop/basics/mangling_keywords2.def deleted file mode 100644 index e8257e78aaa..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/mangling_keywords2.def +++ /dev/null @@ -1,72 +0,0 @@ ---- -enum KotlinKeywordsEnum { - as, - class, - dynamic, - false, - fun, - in, - interface, - is, - null, - object, - package, - super, - this, - throw, - true, - try, - typealias, - val, - var, - when, -}; - -struct KotlinKeywordsStruct { - int as; - int class; - int dynamic; - int false; - int fun; - int in; - int interface; - int is; - int null; - int object; - int package; - int super; - int this; - int throw; - int true; - int try; - int typealias; - int val; - int var; - int when; -}; - -struct KotlinKeywordsStruct createKotlinKeywordsStruct() { - struct KotlinKeywordsStruct s = { - .as = 0, - .class = 0, - .dynamic = 0, - .false = 0, - .fun = 0, - .in = 0, - .interface = 0, - .is = 0, - .null = 0, - .object = 0, - .package = 0, - .super = 0, - .this = 0, - .throw = 0, - .true = 0, - .try = 0, - .typealias = 0, - .val = 0, - .var = 0, - .when = 0, - }; - return s; -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/basics/structAnonym.def b/kotlin-native/backend.native/tests/interop/basics/structAnonym.def deleted file mode 100644 index c92e38778eb..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/structAnonym.def +++ /dev/null @@ -1,192 +0,0 @@ ---- - -/* - * Test of return/send-by-value for aggregate type (struct or union) with anonymous inner struct or union member. - * Specific issues: alignment, packed, nested named and anon struct/union, other anon types (named field of anon struct type; anon bitfield) - */ - -#include - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winitializer-overrides" - -union _GLKVector3 -{ - struct { float x, y, z; }; - struct { float r, g, b; }; - struct { float s, t, p; }; - float v[3]; -}; - -static union _GLKVector3 get_GLKVector3() { - union _GLKVector3 ret = {{1, 2, 3}}; - return ret; -} - -static float hash_GLKVector3(union _GLKVector3 x) { - union _GLKVector3 ret = {{1, 2, 3}}; - return x.x + 2.0f * x.y + 4.0f * x.z; -} - -// trivial alignment: member is already aligned, but this implies implicit larger alignment of the root struct -struct StructAnonRecordMember_ImplicitAlignment { - int32_t a[4]; - struct { - int b __attribute__((aligned(16))); - }; -}; - -static struct StructAnonRecordMember_ImplicitAlignment retByValue_StructAnonRecordMember_ImplicitAlignment() { - struct StructAnonRecordMember_ImplicitAlignment t = { - .a = {1,2,3,4}, - .b = 42 - }; - return t; -} - -struct StructAnonRecordMember_ExplicitAlignment { - char a; - struct { - __attribute__((aligned(4))) - char x; - }; -}; - -static struct StructAnonRecordMember_ExplicitAlignment retByValue_StructAnonRecordMember_ExplicitAlignment() { - struct StructAnonRecordMember_ExplicitAlignment t = { - .a = 'a', - .x = 'x' - }; - return t; -} - -// Deep nesting -struct StructAnonRecordMember_Nested { - int x; - union { // implicitly aligned to 8 bytes due to int64, or 4 bytes at 32-bit arch - int a[2]; - struct { - int64_t b; - }; - }; - char z; - double y; -}; - -static struct StructAnonRecordMember_Nested retByValue_StructAnonRecordMember_Nested() { - struct StructAnonRecordMember_Nested c = { - .x = 37, - .b = 42, - .z = 'z', - .y = 3.14 - }; - return c; -} - -static int sendByValue_StructAnonRecordMember_Nested(struct StructAnonRecordMember_Nested c) { - return c.a[0] + 2 * c.a[1]; -} - -// Basic, 2 levels - -struct StructAnonRecordMember_Complicate { - char first; // __attribute__((aligned(16))); - union { - int a[2]; - union { char c1; int c2; }; - struct { char b1; int64_t b2; }; // implicit 64-bits alignment - }; - char second __attribute__((aligned(16))); - struct { - char x; - struct { int64_t b11, b12; } Y2; - int32_t f __attribute__((aligned(16))); - }; // __attribute__((aligned(16))); - char last; -}; - -#define INIT(T, x) struct T x = \ -{ \ - .first = 'a', \ - .b1 = 'b', \ - .b2 = 42, \ - .second = 's', \ - .last = 'z', \ - .f = 314, \ - .Y2 = {11, 12} \ -} - -static struct StructAnonRecordMember_Complicate retByValue_StructAnonRecordMember_Complicate() { - INIT(StructAnonRecordMember_Complicate, c); - return c; -} - -struct StructAnonRecordMember_Packed { - char first; - union { - int a[2]; - union { char c1; int c2; }; - struct { char b1; int64_t b2; }; - }; - char second; - struct { - char x; - struct { int64_t b11, b12; } Y2; - int32_t f; - } __attribute__((aligned(16))); - char last; -} __attribute__ ((packed)); - -static struct StructAnonRecordMember_Packed retByValue_StructAnonRecordMember_Packed() { - INIT(StructAnonRecordMember_Packed, c); - return c; -} - -// Nested struct may be packed too -#pragma pack(1) -struct StructAnonRecordMember_PragmaPacked { - char first; - union { - int a[2]; - union { char c1; int c2; }; - struct { char b1; int64_t b2; }; - }; - char second; - struct { - char x; - struct { int64_t b11, b12; } Y2; - int32_t f __attribute__((aligned(16))); // another kind of alignment - }; - char last; -} __attribute__ ((packed)); -#pragma pack() - -static struct StructAnonRecordMember_PragmaPacked retByValue_StructAnonRecordMember_PragmaPacked() { - INIT(StructAnonRecordMember_PragmaPacked, c); - return c; -} - -#pragma pack(2) -struct StructAnonRecordMember_Packed2 { - char first; - union { - int a[2]; - union { char c1; int c2; }; - struct { char b1; int64_t b2; }; - }; - char second; - struct { - char x; - struct { int64_t b11, b12; } Y2; - int32_t f; - } __attribute__((aligned(16))); - char last; -} __attribute__ ((packed)); -#pragma pack() - -static struct StructAnonRecordMember_Packed2 retByValue_StructAnonRecordMember_Packed2() { - INIT(StructAnonRecordMember_Packed2, c); - return c; -} - -#pragma clang diagnostic pop diff --git a/kotlin-native/backend.native/tests/interop/basics/structAnonym.kt b/kotlin-native/backend.native/tests/interop/basics/structAnonym.kt deleted file mode 100644 index 38bdc271685..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/structAnonym.kt +++ /dev/null @@ -1,118 +0,0 @@ -@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) - - -import kotlinx.cinterop.* -import kotlin.test.* -import structAnonym.* - - -fun test_GLKVector3() { - get_GLKVector3().useContents { - assertEquals(1.0f, x) - assertEquals(2.0f, g) - assertEquals(3.0f, p) - r = 0.1f - g = 0.2f - b = 0.3f - assertEquals(v[0], r) - assertEquals(v[1], g) - assertEquals(v[2], b) - - val ret = hash_GLKVector3(this.readValue()) - assertEquals(s + 2f * t + 4f * p , ret) - } -} - -fun test_StructAnonRecordMember_ImplicitAlignment() { - retByValue_StructAnonRecordMember_ImplicitAlignment() - .useContents { - assertEquals(1, a[0]) - assertEquals(4, a[3]) - assertEquals(42, b) - } -} - -fun test_StructAnonRecordMember_ExplicitAlignment() { - retByValue_StructAnonRecordMember_ExplicitAlignment() - .useContents { - assertEquals('a', a.toInt().toChar()) - assertEquals('x', x.toInt().toChar()) - } -} - -fun test_StructAnonRecordMember_Nested() { - retByValue_StructAnonRecordMember_Nested() - .useContents { - assertEquals(37, x) - assertEquals(42, b) - assertEquals('z', z.toInt().toChar()) - assertEquals(3.14, y) - - a[0] = 3 - a[1] = 5 - assertEquals(3 + 2*5, sendByValue_StructAnonRecordMember_Nested(this.readValue())) - } -} - -fun test_StructAnonym_Complicate() { - retByValue_StructAnonRecordMember_Complicate() - .useContents{ - assertEquals('a', first.toInt().toChar()) - assertEquals('s', second.toInt().toChar()) - assertEquals('z', last.toInt().toChar()) - assertEquals('b', b1.toInt().toChar()) - assertEquals(42L, b2) - assertEquals(314, f) - assertEquals(11L, Y2.b11) - } -} - -fun test_StructAnonym_Packed() { - retByValue_StructAnonRecordMember_Packed2() - .useContents{ - assertEquals('a', first.toInt().toChar()) - assertEquals('s', second.toInt().toChar()) - assertEquals('z', last.toInt().toChar()) - assertEquals('b', b1.toInt().toChar()) - assertEquals(42L, b2) - assertEquals(314, f) - assertEquals(11L, Y2.b11) - } -} - -fun test_StructAnonym_PragmaPacked() { - retByValue_StructAnonRecordMember_PragmaPacked() - .useContents{ - assertEquals('a', first.toInt().toChar()) - assertEquals('s', second.toInt().toChar()) - assertEquals('z', last.toInt().toChar()) - assertEquals('b', b1.toInt().toChar()) - assertEquals(42L, b2) - assertEquals(314, f) - assertEquals(11L, Y2.b11) - } -} - -fun test_StructAnonym_Packed2() { - retByValue_StructAnonRecordMember_Packed2() - .useContents{ - assertEquals('a', first.toInt().toChar()) - assertEquals('s', second.toInt().toChar()) - assertEquals('z', last.toInt().toChar()) - assertEquals('b', b1.toInt().toChar()) - assertEquals(42L, b2) - assertEquals(314, f) - assertEquals(11L, Y2.b11) - } -} - -fun main() { - test_GLKVector3() - test_StructAnonRecordMember_ImplicitAlignment() - test_StructAnonRecordMember_ExplicitAlignment() - test_StructAnonRecordMember_Nested() - test_StructAnonym_Complicate() - test_StructAnonym_Packed() - test_StructAnonym_PragmaPacked() - test_StructAnonym_Packed2() -} diff --git a/kotlin-native/backend.native/tests/interop/basics/typedefs.def b/kotlin-native/backend.native/tests/interop/basics/typedefs.def deleted file mode 100644 index 97880cddca5..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/typedefs.def +++ /dev/null @@ -1,2 +0,0 @@ ---- -typedef int my_int; \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/basics/types.kt b/kotlin-native/backend.native/tests/interop/basics/types.kt deleted file mode 100644 index 68609c2c63c..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/types.kt +++ /dev/null @@ -1,33 +0,0 @@ -@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) - -import kotlinx.cinterop.* -import kotlin.native.* -import kotlin.test.* -import ctypes.* - -fun main() { - getStructWithConstFields().useContents { - assertEquals(111, x) - assertEquals(222, y) - } - - assertEquals(1u, ForwardDeclaredEnum.ONE.value) - - assertEquals(6, vlaSum(3, cValuesOf(1, 2, 3))) - assertEquals(10, vlaSum2D(2, cValuesOf(1, 2, 3, 4))) - assertEquals(21, vlaSum2DBothDimensions(2, 3, cValuesOf(1, 2, 3, 4, 5, 6))) - - // Not supported by clang: - // assertEquals(10, vlaSum2DForward(cValuesOf(1, 2, 3, 4), 2)) - - assertEquals(0u, StrictEnum1.StrictEnum1A.value) - assertEquals(1u, StrictEnum2.StrictEnum2B.value) - assertEquals(0u, NonStrictEnum1A) - assertEquals(1u, NonStrictEnum2B) - assertEquals(1, EnumCharBase.EnumCharBaseB.value) - assertEquals(3, sendEnum(EnumCharBase.EnumCharBaseB)) - assertEquals('a'.toByte(), EnumExplicitCharA) - assertEquals('b'.toByte(), EnumExplicitCharB) - assertEquals(EnumExplicitCharA, EnumExplicitCharDup) -} - diff --git a/kotlin-native/backend.native/tests/interop/basics/unable_to_import.def b/kotlin-native/backend.native/tests/interop/basics/unable_to_import.def deleted file mode 100644 index a877fb6c03c..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/unable_to_import.def +++ /dev/null @@ -1,10 +0,0 @@ ---- -int global; -#define global bad macro - -void foo(void); -#define foo < - -// Setter for x should not be generated. -typedef const int cint; -cint x; diff --git a/kotlin-native/backend.native/tests/interop/basics/unsupported.kt b/kotlin-native/backend.native/tests/interop/basics/unsupported.kt deleted file mode 100644 index 08bfe60a730..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/unsupported.kt +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -import kotlin.test.* -import cunsupported.* - -fun main(args: Array) { - noAttr() - noTargetAttr() -} diff --git a/kotlin-native/backend.native/tests/interop/basics/values.kt b/kotlin-native/backend.native/tests/interop/basics/values.kt deleted file mode 100644 index 36f409bf6bc..00000000000 --- a/kotlin-native/backend.native/tests/interop/basics/values.kt +++ /dev/null @@ -1,12 +0,0 @@ -@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) - -import kotlinx.cinterop.* -import kotlin.test.* -import cvalues.* - -fun main() { - assertTrue(isNullString(null)) - assertTrue(isNullWString(null)) - assertFalse(isNullString("a")) - assertFalse(isNullWString("b")) -} diff --git a/kotlin-native/backend.native/tests/interop/exceptions/cCallback.cpp b/kotlin-native/backend.native/tests/interop/exceptions/cCallback.cpp deleted file mode 100644 index be05f5cda28..00000000000 --- a/kotlin-native/backend.native/tests/interop/exceptions/cCallback.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include - -extern "C" void runAndCatch(void(*f)(void)) { - try { - f(); - } catch (...) { - printf("CATCH IN C++!\n"); - } -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/exceptions/cCallback.def b/kotlin-native/backend.native/tests/interop/exceptions/cCallback.def deleted file mode 100644 index e37047b646d..00000000000 --- a/kotlin-native/backend.native/tests/interop/exceptions/cCallback.def +++ /dev/null @@ -1,5 +0,0 @@ -language = C - ---- - -void runAndCatch(void(*f)(void)); \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/exceptions/cCallback.kt b/kotlin-native/backend.native/tests/interop/exceptions/cCallback.kt deleted file mode 100644 index c51d38e297c..00000000000 --- a/kotlin-native/backend.native/tests/interop/exceptions/cCallback.kt +++ /dev/null @@ -1,13 +0,0 @@ -@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) - -import kotlinx.cinterop.staticCFunction -import cCallback.runAndCatch - -fun throwingCallback() { - throw IllegalStateException("Kotlin Exception!") -} - - -fun main() { - runAndCatch(staticCFunction(::throwingCallback)) -} diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java index b0c311f519c..eeb89b236b5 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java @@ -4867,6 +4867,128 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe public void testToKString() throws Exception { runTest("compiler/testData/codegen/box/cinterop/toKString.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class Basics { + @Test + @TestMetadata("1.kt") + public void test1() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/1.kt"); + } + + @Test + @TestMetadata("3.kt") + public void test3() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/3.kt"); + } + + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("available_processors.kt") + public void testAvailable_processors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/available_processors.kt"); + } + + @Test + @TestMetadata("macros.kt") + public void testMacros() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/macros.kt"); + } + + @Test + @TestMetadata("mangling.kt") + public void testMangling() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling.kt"); + } + + @Test + @TestMetadata("mangling2.kt") + public void testMangling2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling2.kt"); + } + + @Test + @TestMetadata("mangling_keywords.kt") + public void testMangling_keywords() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt"); + } + + @Test + @TestMetadata("mangling_keywords2.kt") + public void testMangling_keywords2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt"); + } + + @Test + @TestMetadata("structAnonym.kt") + public void testStructAnonym() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structAnonym.kt"); + } + + @Test + @TestMetadata("structs.kt") + public void testStructs() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structs.kt"); + } + + @Test + @TestMetadata("types.kt") + public void testTypes() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/types.kt"); + } + + @Test + @TestMetadata("union.kt") + public void testUnion() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/union.kt"); + } + + @Test + @TestMetadata("unsupported.kt") + public void testUnsupported() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/unsupported.kt"); + } + + @Test + @TestMetadata("values.kt") + public void testValues() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/values.kt"); + } + + @Test + @TestMetadata("vectors.kt") + public void testVectors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/vectors.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("cCallback.kt") + public void testCCallback() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt"); + } + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java index b9d00540f30..e9a78cb9cdb 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java @@ -4977,6 +4977,132 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB public void testToKString() throws Exception { runTest("compiler/testData/codegen/box/cinterop/toKString.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Basics { + @Test + @TestMetadata("1.kt") + public void test1() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/1.kt"); + } + + @Test + @TestMetadata("3.kt") + public void test3() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/3.kt"); + } + + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("available_processors.kt") + public void testAvailable_processors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/available_processors.kt"); + } + + @Test + @TestMetadata("macros.kt") + public void testMacros() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/macros.kt"); + } + + @Test + @TestMetadata("mangling.kt") + public void testMangling() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling.kt"); + } + + @Test + @TestMetadata("mangling2.kt") + public void testMangling2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling2.kt"); + } + + @Test + @TestMetadata("mangling_keywords.kt") + public void testMangling_keywords() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt"); + } + + @Test + @TestMetadata("mangling_keywords2.kt") + public void testMangling_keywords2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt"); + } + + @Test + @TestMetadata("structAnonym.kt") + public void testStructAnonym() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structAnonym.kt"); + } + + @Test + @TestMetadata("structs.kt") + public void testStructs() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structs.kt"); + } + + @Test + @TestMetadata("types.kt") + public void testTypes() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/types.kt"); + } + + @Test + @TestMetadata("union.kt") + public void testUnion() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/union.kt"); + } + + @Test + @TestMetadata("unsupported.kt") + public void testUnsupported() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/unsupported.kt"); + } + + @Test + @TestMetadata("values.kt") + public void testValues() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/values.kt"); + } + + @Test + @TestMetadata("vectors.kt") + public void testVectors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/vectors.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + @Tag("frontend-fir") + @FirPipeline() + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("cCallback.kt") + public void testCCallback() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt"); + } + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java index 8a529fa4986..a2f7fdf0a33 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java @@ -4757,6 +4757,124 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest public void testToKString() throws Exception { runTest("compiler/testData/codegen/box/cinterop/toKString.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + public class Basics { + @Test + @TestMetadata("1.kt") + public void test1() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/1.kt"); + } + + @Test + @TestMetadata("3.kt") + public void test3() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/3.kt"); + } + + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("available_processors.kt") + public void testAvailable_processors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/available_processors.kt"); + } + + @Test + @TestMetadata("macros.kt") + public void testMacros() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/macros.kt"); + } + + @Test + @TestMetadata("mangling.kt") + public void testMangling() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling.kt"); + } + + @Test + @TestMetadata("mangling2.kt") + public void testMangling2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling2.kt"); + } + + @Test + @TestMetadata("mangling_keywords.kt") + public void testMangling_keywords() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt"); + } + + @Test + @TestMetadata("mangling_keywords2.kt") + public void testMangling_keywords2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt"); + } + + @Test + @TestMetadata("structAnonym.kt") + public void testStructAnonym() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structAnonym.kt"); + } + + @Test + @TestMetadata("structs.kt") + public void testStructs() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structs.kt"); + } + + @Test + @TestMetadata("types.kt") + public void testTypes() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/types.kt"); + } + + @Test + @TestMetadata("union.kt") + public void testUnion() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/union.kt"); + } + + @Test + @TestMetadata("unsupported.kt") + public void testUnsupported() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/unsupported.kt"); + } + + @Test + @TestMetadata("values.kt") + public void testValues() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/values.kt"); + } + + @Test + @TestMetadata("vectors.kt") + public void testVectors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/vectors.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("cCallback.kt") + public void testCCallback() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt"); + } + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java index 2c016942cd8..72ba20611f5 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java @@ -4868,6 +4868,128 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT public void testToKString() throws Exception { runTest("compiler/testData/codegen/box/cinterop/toKString.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Basics { + @Test + @TestMetadata("1.kt") + public void test1() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/1.kt"); + } + + @Test + @TestMetadata("3.kt") + public void test3() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/3.kt"); + } + + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("available_processors.kt") + public void testAvailable_processors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/available_processors.kt"); + } + + @Test + @TestMetadata("macros.kt") + public void testMacros() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/macros.kt"); + } + + @Test + @TestMetadata("mangling.kt") + public void testMangling() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling.kt"); + } + + @Test + @TestMetadata("mangling2.kt") + public void testMangling2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling2.kt"); + } + + @Test + @TestMetadata("mangling_keywords.kt") + public void testMangling_keywords() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords.kt"); + } + + @Test + @TestMetadata("mangling_keywords2.kt") + public void testMangling_keywords2() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/mangling_keywords2.kt"); + } + + @Test + @TestMetadata("structAnonym.kt") + public void testStructAnonym() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structAnonym.kt"); + } + + @Test + @TestMetadata("structs.kt") + public void testStructs() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/structs.kt"); + } + + @Test + @TestMetadata("types.kt") + public void testTypes() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/types.kt"); + } + + @Test + @TestMetadata("union.kt") + public void testUnion() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/union.kt"); + } + + @Test + @TestMetadata("unsupported.kt") + public void testUnsupported() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/unsupported.kt"); + } + + @Test + @TestMetadata("values.kt") + public void testValues() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/values.kt"); + } + + @Test + @TestMetadata("vectors.kt") + public void testVectors() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/basics/vectors.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("cCallback.kt") + public void testCCallback() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/exceptions/cCallback.kt"); + } + } } @Nested diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java index 9af3d22a4e9..0a17ef0775d 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmCodegenBoxTestGenerated.java @@ -4592,6 +4592,26 @@ public class FirWasmCodegenBoxTestGenerated extends AbstractFirWasmCodegenBoxTes public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } } @Nested diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java index 27cb31b4c63..457af149f23 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java @@ -4592,6 +4592,26 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest public void testAllFilesPresentInCinterop() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/basics") + @TestDataPath("$PROJECT_ROOT") + public class Basics { + @Test + public void testAllFilesPresentInBasics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/basics"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/cinterop/exceptions") + @TestDataPath("$PROJECT_ROOT") + public class Exceptions { + @Test + public void testAllFilesPresentInExceptions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/exceptions"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } } @Nested