Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add nested companion class test case #1771

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,48 @@ describe("Tests Kotlin companion objects support", function () {
expect(str).toBe("someString");
});


it("Test Kotlin enum class companion object without a name should be supported", function () {
console.log(com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.Companion);
var stringFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.Companion.getStringFromCompanion();
expect(stringFromCompanion).toBe("testCompanion");

var providedStringFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.Companion.getProvidedStringFromCompanion("providedString");
expect(providedStringFromCompanion).toBe("providedString");

var simpleObjectFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.Companion.getSimpleObjectFromCompanion();
expect(simpleObjectFromCompanion.getSomeString()).toBe("test");

var simpleKotlinObject = new com.tns.tests.kotlin.SimpleKotlinObject();
var providedSimpleObjectFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.Companion.getProvidedSimpleObjectFromCompanion(simpleKotlinObject);
expect(simpleKotlinObject.equals(providedSimpleObjectFromCompanion)).toBe(true);

var stringJvmStaticFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.getStringJvmStaticFromCompanion();
expect(stringJvmStaticFromCompanion).toBe("testCompanion");

var providedStringJvmStaticFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithCompanionWithNestedClass.getProvidedStringJvmStaticFromCompanion("providedString");
expect(providedStringJvmStaticFromCompanion).toBe("providedString");
});

it("Test Kotlin enum class named companion object without a name should be supported", function () {
var stringFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithNamedCompanionWithNestedClass.NamedCompanion.getStringFromNamedCompanion();
expect(stringFromCompanion).toBe("testCompanion");

var providedStringFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithNamedCompanionWithNestedClass.NamedCompanion.getProvidedStringFromNamedCompanion("providedString");
expect(providedStringFromCompanion).toBe("providedString");

var simpleObjectFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithNamedCompanionWithNestedClass.NamedCompanion.getSimpleObjectFromNamedCompanion();
expect(simpleObjectFromCompanion.getSomeString()).toBe("test");

var simpleKotlinObject = new com.tns.tests.kotlin.SimpleKotlinObject();
var providedSimpleObjectFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithNamedCompanionWithNestedClass.NamedCompanion.getProvidedSimpleObjectFromNamedCompanion(simpleKotlinObject);
expect(simpleKotlinObject.equals(providedSimpleObjectFromCompanion)).toBe(true);

var stringJvmStaticFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithNamedCompanionWithNestedClass.getStringJvmStaticFromNamedCompanion();
expect(stringJvmStaticFromCompanion).toBe("testCompanion");

var providedStringJvmStaticFromCompanion = com.tns.tests.kotlin.companions.KotlinEnumClassWithNamedCompanionWithNestedClass.getProvidedStringJvmStaticFromNamedCompanion("providedString");
expect(providedStringJvmStaticFromCompanion).toBe("providedString");
});

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.tns.tests.kotlin.companions

import com.tns.tests.kotlin.SimpleKotlinObject


enum class KotlinEnumClassWithCompanionWithNestedClass {
TEST_ENTRY;

companion object {
fun getStringFromCompanion(): String = "testCompanion"
fun getProvidedStringFromCompanion(providedString: String) = providedString

fun getSimpleObjectFromCompanion(): SimpleKotlinObject = SimpleKotlinObject()
fun getProvidedSimpleObjectFromCompanion(providedSimpleObject: SimpleKotlinObject) =
providedSimpleObject

@JvmStatic
fun getStringJvmStaticFromCompanion(): String = "testCompanion"

@JvmStatic
fun getProvidedStringJvmStaticFromCompanion(providedString: String) = providedString

class TestClass {

}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.tns.tests.kotlin.companions

import com.tns.tests.kotlin.SimpleKotlinObject

enum class KotlinEnumClassWithNamedCompanionWithNestedClass {
TEST_ENTRY;

companion object NamedCompanion {
fun getStringFromNamedCompanion(): String = "testCompanion"
fun getProvidedStringFromNamedCompanion(providedString: String) = providedString

fun getSimpleObjectFromNamedCompanion(): SimpleKotlinObject = SimpleKotlinObject()
fun getProvidedSimpleObjectFromNamedCompanion(providedSimpleObject: SimpleKotlinObject) =
providedSimpleObject

@JvmStatic
fun getStringJvmStaticFromNamedCompanion(): String = "testCompanion"

@JvmStatic
fun getProvidedStringJvmStaticFromNamedCompanion(providedString: String) =
providedString


class TestClass {

}
}

}