From 837365364e2a3d7125e3a0eae094060609b2d852 Mon Sep 17 00:00:00 2001 From: Thomas Heigl Date: Tue, 4 Apr 2023 18:38:46 +0200 Subject: [PATCH] Experimental support for Kotlin tests --- pom.xml | 63 ++++++++++++++++++- .../com.esotericsoftware.kryo/LambdaTest.kt | 33 ++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 test-kotlin/com.esotericsoftware.kryo/LambdaTest.kt diff --git a/pom.xml b/pom.xml index 4715b240b..aaf055a7f 100644 --- a/pom.xml +++ b/pom.xml @@ -52,6 +52,8 @@ 1.8 UTF-8 5.9.2 + 1.8.20 + true @@ -109,7 +111,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.5.1 ${javac.target} ${javac.target} @@ -339,6 +341,63 @@ + + + kotlin + + + !skipKotlin + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source + generate-test-sources + + add-test-source + + + + test-kotlin + + + + + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + test-compile + test-compile + + test-compile + + + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + test + + + jdk11ge @@ -360,6 +419,7 @@ + test-kotlin test-jdk11 @@ -406,6 +466,7 @@ + test-kotlin test-jdk11 test-jdk14 diff --git a/test-kotlin/com.esotericsoftware.kryo/LambdaTest.kt b/test-kotlin/com.esotericsoftware.kryo/LambdaTest.kt new file mode 100644 index 000000000..e55de462a --- /dev/null +++ b/test-kotlin/com.esotericsoftware.kryo/LambdaTest.kt @@ -0,0 +1,33 @@ +package com.esotericsoftware.kryo + +import com.esotericsoftware.kryo.io.Input +import com.esotericsoftware.kryo.io.Output +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +class LambdaTest { + private class Example(private val p: (Long) -> String) { + constructor() : this({ it.toString() }) + } + + @Test + @Disabled("Expected to fail") + fun testLambda() { + val kryo = Kryo().apply { + isRegistrationRequired = false + } + + val example = Example() + + val bytes = Output(1024).use { output -> + kryo.writeClassAndObject(output, example) + output.toBytes() + } + + val deserialized = Input(bytes).use { input -> + kryo.readClassAndObject(input) + } + + println(deserialized) + } +}