Skip to content

Commit 0e7b817

Browse files
committed
Use simple class names in test data (fix)
1 parent fa87f20 commit 0e7b817

File tree

2 files changed

+47
-45
lines changed

2 files changed

+47
-45
lines changed

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/CodeGenerationTests.kt

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,23 @@ class CodeGenerationTests : BaseTest() {
2525

2626
val personShortName = Person::class.simpleName!!
2727

28-
val dfName = (ColumnsContainer::class).qualifiedName
29-
val dfRowName = (DataRow::class).qualifiedName
30-
val dataCol = (DataColumn::class).qualifiedName!!
31-
val dataRow = (DataRow::class).qualifiedName!!
32-
val colGroup = (ColumnGroup::class).qualifiedName!!
28+
val dfName = (ColumnsContainer::class).simpleName!!
29+
val dfRowName = (DataRow::class).simpleName!!
30+
val dataCol = (DataColumn::class).simpleName!!
31+
val dataRow = (DataRow::class).simpleName!!
32+
val colGroup = (ColumnGroup::class).simpleName!!
33+
val stringName = String::class.simpleName!!
34+
val intName = Int::class.simpleName!!
3335

3436
fun expectedProperties(fullTypeName: String, shortTypeName: String) = """
35-
val $dfName<$fullTypeName>.age: $dataCol<kotlin.Int> @JvmName("${shortTypeName}_age") get() = this["age"] as $dataCol<kotlin.Int>
36-
val $dfRowName<$fullTypeName>.age: kotlin.Int @JvmName("${shortTypeName}_age") get() = this["age"] as kotlin.Int
37-
val $dfName<$fullTypeName>.city: $dataCol<kotlin.String?> @JvmName("${shortTypeName}_city") get() = this["city"] as $dataCol<kotlin.String?>
38-
val $dfRowName<$fullTypeName>.city: kotlin.String? @JvmName("${shortTypeName}_city") get() = this["city"] as kotlin.String?
39-
val $dfName<$fullTypeName>.name: $dataCol<kotlin.String> @JvmName("${shortTypeName}_name") get() = this["name"] as $dataCol<kotlin.String>
40-
val $dfRowName<$fullTypeName>.name: kotlin.String @JvmName("${shortTypeName}_name") get() = this["name"] as kotlin.String
41-
val $dfName<$fullTypeName>.weight: $dataCol<kotlin.Int?> @JvmName("${shortTypeName}_weight") get() = this["weight"] as $dataCol<kotlin.Int?>
42-
val $dfRowName<$fullTypeName>.weight: kotlin.Int? @JvmName("${shortTypeName}_weight") get() = this["weight"] as kotlin.Int?
37+
val $dfName<$fullTypeName>.age: $dataCol<$intName> @JvmName("${shortTypeName}_age") get() = this["age"] as $dataCol<$intName>
38+
val $dfRowName<$fullTypeName>.age: $intName @JvmName("${shortTypeName}_age") get() = this["age"] as $intName
39+
val $dfName<$fullTypeName>.city: $dataCol<$stringName?> @JvmName("${shortTypeName}_city") get() = this["city"] as $dataCol<$stringName?>
40+
val $dfRowName<$fullTypeName>.city: $stringName? @JvmName("${shortTypeName}_city") get() = this["city"] as $stringName?
41+
val $dfName<$fullTypeName>.name: $dataCol<$stringName> @JvmName("${shortTypeName}_name") get() = this["name"] as $dataCol<$stringName>
42+
val $dfRowName<$fullTypeName>.name: $stringName @JvmName("${shortTypeName}_name") get() = this["name"] as $stringName
43+
val $dfName<$fullTypeName>.weight: $dataCol<$intName?> @JvmName("${shortTypeName}_weight") get() = this["weight"] as $dataCol<$intName?>
44+
val $dfRowName<$fullTypeName>.weight: $intName? @JvmName("${shortTypeName}_weight") get() = this["weight"] as $intName?
4345
""".trimIndent()
4446

4547
@Test
@@ -95,23 +97,23 @@ class CodeGenerationTests : BaseTest() {
9597
@DataSchema(isOpen = false)
9698
interface $type1
9799
98-
val $dfName<$type1>.city: $dataCol<kotlin.String?> @JvmName("${type1}_city") get() = this["city"] as $dataCol<kotlin.String?>
99-
val $dfRowName<$type1>.city: kotlin.String? @JvmName("${type1}_city") get() = this["city"] as kotlin.String?
100-
val $dfName<$type1>.name: $dataCol<kotlin.String> @JvmName("${type1}_name") get() = this["name"] as $dataCol<kotlin.String>
101-
val $dfRowName<$type1>.name: kotlin.String @JvmName("${type1}_name") get() = this["name"] as kotlin.String
100+
val $dfName<$type1>.city: $dataCol<$stringName?> @JvmName("${type1}_city") get() = this["city"] as $dataCol<$stringName?>
101+
val $dfRowName<$type1>.city: $stringName? @JvmName("${type1}_city") get() = this["city"] as $stringName?
102+
val $dfName<$type1>.name: $dataCol<$stringName> @JvmName("${type1}_name") get() = this["name"] as $dataCol<$stringName>
103+
val $dfRowName<$type1>.name: $stringName @JvmName("${type1}_name") get() = this["name"] as $stringName
102104
103105
""".trimIndent()
104106

105107
val declaration2 = """
106108
@DataSchema(isOpen = false)
107109
interface $type2
108110
109-
val $dfName<$type2>.age: $dataCol<kotlin.Int> @JvmName("${type2}_age") get() = this["age"] as $dataCol<kotlin.Int>
110-
val $dfRowName<$type2>.age: kotlin.Int @JvmName("${type2}_age") get() = this["age"] as kotlin.Int
111+
val $dfName<$type2>.age: $dataCol<$intName> @JvmName("${type2}_age") get() = this["age"] as $dataCol<$intName>
112+
val $dfRowName<$type2>.age: $intName @JvmName("${type2}_age") get() = this["age"] as $intName
111113
val $dfName<$type2>.nameAndCity: $colGroup<$type1> @JvmName("${type2}_nameAndCity") get() = this["nameAndCity"] as $colGroup<$type1>
112114
val $dfRowName<$type2>.nameAndCity: $dataRow<$type1> @JvmName("${type2}_nameAndCity") get() = this["nameAndCity"] as $dataRow<$type1>
113-
val $dfName<$type2>.weight: $dataCol<kotlin.Int?> @JvmName("${type2}_weight") get() = this["weight"] as $dataCol<kotlin.Int?>
114-
val $dfRowName<$type2>.weight: kotlin.Int? @JvmName("${type2}_weight") get() = this["weight"] as kotlin.Int?
115+
val $dfName<$type2>.weight: $dataCol<$intName?> @JvmName("${type2}_weight") get() = this["weight"] as $dataCol<$intName?>
116+
val $dfRowName<$type2>.weight: $intName? @JvmName("${type2}_weight") get() = this["weight"] as $intName?
115117
""".trimIndent()
116118

117119
val expectedConverter = "it.cast<$type2>()"
@@ -128,7 +130,7 @@ class CodeGenerationTests : BaseTest() {
128130
interface $personClass
129131
""".trimIndent() + "\n" + expectedProperties(personClassName, personShortName)
130132

131-
val code = CodeGenerator.create().generate<Person>(InterfaceGenerationMode.NoFields, extensionProperties = true).declarations
133+
val code = CodeGenerator.create(useFqNames = false).generate<Person>(InterfaceGenerationMode.NoFields, extensionProperties = true).declarations
132134
code shouldBe expected
133135
}
134136

@@ -168,7 +170,7 @@ class CodeGenerationTests : BaseTest() {
168170

169171
@Test
170172
fun `empty interface with properties`() {
171-
val codeGen = CodeGenerator.create()
173+
val codeGen = CodeGenerator.create(useFqNames = false)
172174
val code = codeGen.generate(df.schema(), "Person", false, true, true).code.declarations
173175
val expected = """
174176
@DataSchema

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/ReplCodeGenTests.kt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ import org.junit.Test
1919

2020
class ReplCodeGenTests : BaseTest() {
2121

22+
val dfName = (ColumnsContainer::class).simpleName!!
23+
val dfRowName = (DataRow::class).simpleName!!
24+
val dataCol = (DataColumn::class).simpleName!!
25+
val intName = Int::class.simpleName!!
26+
val stringName = String::class.simpleName!!
27+
2228
class Test1 {
2329
@DataSchema(isOpen = false)
2430
interface _DataFrameType
@@ -64,24 +70,21 @@ class ReplCodeGenTests : BaseTest() {
6470
val repl = ReplCodeGenerator.create()
6571
val code = repl.process(df).declarations
6672

67-
val dfName = (ColumnsContainer::class).qualifiedName
68-
val dfRowName = (DataRow::class).qualifiedName
69-
val dataCol = (DataColumn::class).qualifiedName!!
7073
val marker = ReplCodeGeneratorImpl.markerInterfacePrefix
7174
val markerFull = Test1._DataFrameType::class.qualifiedName!!
7275

7376
val expected = """
7477
@DataSchema(isOpen = false)
7578
interface $marker
7679
77-
val $dfName<$marker>.age: $dataCol<kotlin.Int> @JvmName("${marker}_age") get() = this["age"] as $dataCol<kotlin.Int>
78-
val $dfRowName<$marker>.age: kotlin.Int @JvmName("${marker}_age") get() = this["age"] as kotlin.Int
79-
val $dfName<$marker>.city: $dataCol<kotlin.String?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<kotlin.String?>
80-
val $dfRowName<$marker>.city: kotlin.String? @JvmName("${marker}_city") get() = this["city"] as kotlin.String?
81-
val $dfName<$marker>.name: $dataCol<kotlin.String> @JvmName("${marker}_name") get() = this["name"] as $dataCol<kotlin.String>
82-
val $dfRowName<$marker>.name: kotlin.String @JvmName("${marker}_name") get() = this["name"] as kotlin.String
83-
val $dfName<$marker>.weight: $dataCol<kotlin.Int?> @JvmName("${marker}_weight") get() = this["weight"] as $dataCol<kotlin.Int?>
84-
val $dfRowName<$marker>.weight: kotlin.Int? @JvmName("${marker}_weight") get() = this["weight"] as kotlin.Int?
80+
val $dfName<$marker>.age: $dataCol<$intName> @JvmName("${marker}_age") get() = this["age"] as $dataCol<$intName>
81+
val $dfRowName<$marker>.age: $intName @JvmName("${marker}_age") get() = this["age"] as $intName
82+
val $dfName<$marker>.city: $dataCol<$stringName?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<$stringName?>
83+
val $dfRowName<$marker>.city: $stringName? @JvmName("${marker}_city") get() = this["city"] as $stringName?
84+
val $dfName<$marker>.name: $dataCol<$stringName> @JvmName("${marker}_name") get() = this["name"] as $dataCol<$stringName>
85+
val $dfRowName<$marker>.name: $stringName @JvmName("${marker}_name") get() = this["name"] as $stringName
86+
val $dfName<$marker>.weight: $dataCol<$intName?> @JvmName("${marker}_weight") get() = this["weight"] as $dataCol<$intName?>
87+
val $dfRowName<$marker>.weight: $intName? @JvmName("${marker}_weight") get() = this["weight"] as $intName?
8588
""".trimIndent()
8689
code shouldBe expected
8790

@@ -95,8 +98,8 @@ class ReplCodeGenTests : BaseTest() {
9598
@DataSchema(isOpen = false)
9699
interface $marker3 : $markerFull
97100
98-
val $dfName<$marker3>.city: $dataCol<kotlin.String> @JvmName("${marker3}_city") get() = this["city"] as $dataCol<kotlin.String>
99-
val $dfRowName<$marker3>.city: kotlin.String @JvmName("${marker3}_city") get() = this["city"] as kotlin.String
101+
val $dfName<$marker3>.city: $dataCol<$stringName> @JvmName("${marker3}_city") get() = this["city"] as $dataCol<$stringName>
102+
val $dfRowName<$marker3>.city: $stringName @JvmName("${marker3}_city") get() = this["city"] as $stringName
100103
""".trimIndent()
101104

102105
code3 shouldBe expected3
@@ -111,8 +114,8 @@ class ReplCodeGenTests : BaseTest() {
111114
@DataSchema(isOpen = false)
112115
interface $marker5 : $markerFull
113116
114-
val $dfName<$marker5>.weight: $dataCol<kotlin.Int> @JvmName("${marker5}_weight") get() = this["weight"] as $dataCol<kotlin.Int>
115-
val $dfRowName<$marker5>.weight: kotlin.Int @JvmName("${marker5}_weight") get() = this["weight"] as kotlin.Int
117+
val $dfName<$marker5>.weight: $dataCol<$intName> @JvmName("${marker5}_weight") get() = this["weight"] as $dataCol<$intName>
118+
val $dfRowName<$marker5>.weight: $intName @JvmName("${marker5}_weight") get() = this["weight"] as $intName
116119
""".trimIndent()
117120
code5 shouldBe expected5
118121

@@ -146,18 +149,15 @@ class ReplCodeGenTests : BaseTest() {
146149
repl.process(typed.select { city and weight })
147150
repl.process<Test1._DataFrameType1>() shouldBe "" // processed wrong marker (doesn't implement Test2.DataFrameType)
148151

149-
val dfName = (ColumnsContainer::class).qualifiedName
150-
val dfRowName = (DataRow::class).qualifiedName
151-
val dataCol = (DataColumn::class).qualifiedName!!
152152
val marker = Test2._DataFrameType2::class.simpleName!!
153153
val expected = """
154154
@DataSchema(isOpen = false)
155155
interface $marker : ${Test2._DataFrameType::class.qualifiedName}
156156
157-
val $dfName<$marker>.city: $dataCol<kotlin.String?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<kotlin.String?>
158-
val $dfRowName<$marker>.city: kotlin.String? @JvmName("${marker}_city") get() = this["city"] as kotlin.String?
159-
val $dfName<$marker>.weight: $dataCol<kotlin.Int?> @JvmName("${marker}_weight") get() = this["weight"] as $dataCol<kotlin.Int?>
160-
val $dfRowName<$marker>.weight: kotlin.Int? @JvmName("${marker}_weight") get() = this["weight"] as kotlin.Int?
157+
val $dfName<$marker>.city: $dataCol<$stringName?> @JvmName("${marker}_city") get() = this["city"] as $dataCol<$stringName?>
158+
val $dfRowName<$marker>.city: $stringName? @JvmName("${marker}_city") get() = this["city"] as $stringName?
159+
val $dfName<$marker>.weight: $dataCol<$intName?> @JvmName("${marker}_weight") get() = this["weight"] as $dataCol<$intName?>
160+
val $dfRowName<$marker>.weight: $intName? @JvmName("${marker}_weight") get() = this["weight"] as $intName?
161161
""".trimIndent()
162162

163163
val code = repl.process(typed).declarations.trimIndent()

0 commit comments

Comments
 (0)