[CInterop] Add test for kotlin keywords
This commit is contained in:
committed by
Sergey Bogolepov
parent
a3acfb5f51
commit
06dba7fc09
@@ -3467,6 +3467,14 @@ 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("auxiliaryCppSources") {
|
||||
// We need to provide empty def file to create correct `KonanInteropTask`.
|
||||
it.defFile 'interop/auxiliary_sources/auxiliaryCppSources.def'
|
||||
@@ -3670,6 +3678,18 @@ interopTest("interop_mangling2") {
|
||||
interop = 'cmangling2'
|
||||
}
|
||||
|
||||
interopTest("interop_mangling_keywords") {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
source = "interop/basics/mangling_keywords.kt"
|
||||
interop = 'cmangling_keywords'
|
||||
}
|
||||
|
||||
interopTest("interop_mangling_keywords2") {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
source = "interop/basics/mangling_keywords2.kt"
|
||||
interop = 'cmangling_keywords2'
|
||||
}
|
||||
|
||||
interopTest("interop_auxiliarySources") {
|
||||
disabled = (project.testTarget == 'wasm32') // No interop for wasm yet.
|
||||
source = "interop/auxiliary_sources/main.kt"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
#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"
|
||||
@@ -0,0 +1,27 @@
|
||||
import kotlin.test.*
|
||||
import mangling_keywords.*
|
||||
|
||||
fun main() {
|
||||
// Check that all Kotlin keywords are imported and mangled.
|
||||
assertEquals("as", `as`)
|
||||
assertEquals("class", `class`)
|
||||
assertEquals("dynamic", `dynamic`)
|
||||
assertEquals("false", `false`)
|
||||
assertEquals("fun", `fun`)
|
||||
assertEquals("in", `in`)
|
||||
assertEquals("interface", `interface`)
|
||||
assertEquals("is", `is`)
|
||||
assertEquals("null", `null`)
|
||||
assertEquals("object", `object`)
|
||||
assertEquals("package", `package`)
|
||||
assertEquals("super", `super`)
|
||||
assertEquals("this", `this`)
|
||||
assertEquals("throw", `throw`)
|
||||
assertEquals("true", `true`)
|
||||
assertEquals("try", `try`)
|
||||
assertEquals("typealias", `typealias`)
|
||||
assertEquals("val", `val`)
|
||||
assertEquals("var", `var`)
|
||||
assertEquals("when", `when`)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import kotlin.test.*
|
||||
import mangling_keywords2.*
|
||||
import kotlinx.cinterop.useContents
|
||||
|
||||
fun main() {
|
||||
// Check that all Kotlin keywords are imported and mangled.
|
||||
createKotlinKeywordsStruct().useContents {
|
||||
assertEquals(0, `as`)
|
||||
assertEquals(0, `class`)
|
||||
assertEquals(0, `dynamic`)
|
||||
assertEquals(0, `false`)
|
||||
assertEquals(0, `fun`)
|
||||
assertEquals(0, `in`)
|
||||
assertEquals(0, `interface`)
|
||||
assertEquals(0, `is`)
|
||||
assertEquals(0, `null`)
|
||||
assertEquals(0, `object`)
|
||||
assertEquals(0, `package`)
|
||||
assertEquals(0, `super`)
|
||||
assertEquals(0, `this`)
|
||||
assertEquals(0, `throw`)
|
||||
assertEquals(0, `true`)
|
||||
assertEquals(0, `try`)
|
||||
assertEquals(0, `typealias`)
|
||||
assertEquals(0, `val`)
|
||||
assertEquals(0, `var`)
|
||||
assertEquals(0, `when`)
|
||||
}
|
||||
|
||||
assertEquals(KotlinKeywordsEnum.`as`, KotlinKeywordsEnum.`as`)
|
||||
assertEquals(KotlinKeywordsEnum.`class`, KotlinKeywordsEnum.`class`)
|
||||
assertEquals(KotlinKeywordsEnum.`dynamic`, KotlinKeywordsEnum.`dynamic`)
|
||||
assertEquals(KotlinKeywordsEnum.`false`, KotlinKeywordsEnum.`false`)
|
||||
assertEquals(KotlinKeywordsEnum.`fun`, KotlinKeywordsEnum.`fun`)
|
||||
assertEquals(KotlinKeywordsEnum.`in`, KotlinKeywordsEnum.`in`)
|
||||
assertEquals(KotlinKeywordsEnum.`interface`, KotlinKeywordsEnum.`interface`)
|
||||
assertEquals(KotlinKeywordsEnum.`is`, KotlinKeywordsEnum.`is`)
|
||||
assertEquals(KotlinKeywordsEnum.`null`, KotlinKeywordsEnum.`null`)
|
||||
assertEquals(KotlinKeywordsEnum.`object`, KotlinKeywordsEnum.`object`)
|
||||
assertEquals(KotlinKeywordsEnum.`package`, KotlinKeywordsEnum.`package`)
|
||||
assertEquals(KotlinKeywordsEnum.`super`, KotlinKeywordsEnum.`super`)
|
||||
assertEquals(KotlinKeywordsEnum.`this`, KotlinKeywordsEnum.`this`)
|
||||
assertEquals(KotlinKeywordsEnum.`throw`, KotlinKeywordsEnum.`throw`)
|
||||
assertEquals(KotlinKeywordsEnum.`true`, KotlinKeywordsEnum.`true`)
|
||||
assertEquals(KotlinKeywordsEnum.`try`, KotlinKeywordsEnum.`try`)
|
||||
assertEquals(KotlinKeywordsEnum.`typealias`, KotlinKeywordsEnum.`typealias`)
|
||||
assertEquals(KotlinKeywordsEnum.`val`, KotlinKeywordsEnum.`val`)
|
||||
assertEquals(KotlinKeywordsEnum.`var`, KotlinKeywordsEnum.`var`)
|
||||
assertEquals(KotlinKeywordsEnum.`when`, KotlinKeywordsEnum.`when`)
|
||||
}
|
||||
Reference in New Issue
Block a user