|
1 | 1 | package org.jetbrains.kotlinx.dataframe.codeGen |
2 | 2 |
|
3 | 3 | import io.kotest.matchers.shouldBe |
| 4 | +import io.kotest.matchers.string.shouldContain |
4 | 5 | import io.kotest.matchers.string.shouldNotBeEmpty |
| 6 | +import io.kotest.matchers.string.shouldNotContain |
5 | 7 | import org.jetbrains.kotlinx.dataframe.AnyRow |
6 | 8 | import org.jetbrains.kotlinx.dataframe.ColumnsScope |
7 | 9 | import org.jetbrains.kotlinx.dataframe.DataColumn |
8 | 10 | import org.jetbrains.kotlinx.dataframe.DataRow |
9 | 11 | import org.jetbrains.kotlinx.dataframe.annotations.DataSchema |
10 | 12 | import org.jetbrains.kotlinx.dataframe.api.add |
11 | 13 | import org.jetbrains.kotlinx.dataframe.api.asFrame |
| 14 | +import org.jetbrains.kotlinx.dataframe.api.columnOf |
12 | 15 | import org.jetbrains.kotlinx.dataframe.api.convert |
13 | 16 | import org.jetbrains.kotlinx.dataframe.api.dataFrameOf |
14 | 17 | import org.jetbrains.kotlinx.dataframe.api.filter |
@@ -300,4 +303,39 @@ class ReplCodeGenTests : BaseTest() { |
300 | 303 | val $dfRowName<_DataFrameType2>.leaf: $dfRowName<_DataFrameType3> @JvmName("_DataFrameType2_leaf") get() = this["leaf"] as $dfRowName<_DataFrameType3> |
301 | 304 | """.trimIndent() |
302 | 305 | } |
| 306 | + |
| 307 | + object TestColumnOrderInGroup { |
| 308 | + @DataSchema |
| 309 | + interface Nested { |
| 310 | + val x: Int |
| 311 | + val y: String |
| 312 | + } |
| 313 | + |
| 314 | + @DataSchema |
| 315 | + interface Base { |
| 316 | + val nested: Nested |
| 317 | + val extra: Int? |
| 318 | + } |
| 319 | + |
| 320 | + val df = dataFrameOf( |
| 321 | + "nested" to columnOf( |
| 322 | + "y" to columnOf("hello"), |
| 323 | + "x" to columnOf(42), |
| 324 | + ), |
| 325 | + "extra" to columnOf(1), |
| 326 | + ) |
| 327 | + } |
| 328 | + |
| 329 | + @Test |
| 330 | + fun `column order in nested group should not cause override`() { |
| 331 | + val repl = ReplCodeGenerator.create() |
| 332 | + repl.process<TestColumnOrderInGroup.Nested>() |
| 333 | + repl.process<TestColumnOrderInGroup.Base>() |
| 334 | + val c = repl.process(TestColumnOrderInGroup.df) |
| 335 | + |
| 336 | + // extra: Int? → Int — valid |
| 337 | + c.declarations shouldContain "override val extra" |
| 338 | + // nested: Group{y,x} vs Group{x,y} — semantically the same, no need to override |
| 339 | + c.declarations shouldNotContain "override val nested" |
| 340 | + } |
303 | 341 | } |
0 commit comments