@@ -5,11 +5,15 @@ import org.jetbrains.kotlinx.dataframe.DataFrame
55import org.jetbrains.kotlinx.dataframe.DataRow
66import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
77import org.jetbrains.kotlinx.dataframe.api.add
8+ import org.jetbrains.kotlinx.dataframe.api.after
89import org.jetbrains.kotlinx.dataframe.api.cast
910import org.jetbrains.kotlinx.dataframe.api.columnOf
1011import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
1112import org.jetbrains.kotlinx.dataframe.api.generateCode
13+ import org.jetbrains.kotlinx.dataframe.api.move
1214import org.jetbrains.kotlinx.dataframe.api.schema
15+ import org.jetbrains.kotlinx.dataframe.api.update
16+ import org.jetbrains.kotlinx.dataframe.api.with
1317import org.jetbrains.kotlinx.dataframe.impl.codeGen.ReplCodeGenerator
1418import org.jetbrains.kotlinx.dataframe.io.readJsonStr
1519import org.jetbrains.kotlinx.dataframe.schema.CompareResult.IsDerived
@@ -196,4 +200,48 @@ class MatchSchemeTests {
196200 scheme1.compare(scheme3, STRICT ) shouldBe None
197201 scheme3.compare(scheme1, STRICT ) shouldBe None
198202 }
203+
204+ @Test
205+ fun `comparison with order` () {
206+ val scheme1 = dataFrameOf(
207+ " a" to columnOf(1 , 2 , 3 , 4 ),
208+ " b" to columnOf(1.0 , 2.0 , 3.0 , 4.0 ),
209+ ).schema()
210+
211+ val scheme1a = dataFrameOf(
212+ " a" to columnOf(1 , 2 , 3 , 4 ),
213+ " b" to columnOf(1.0 , 2.0 , 3.0 , 4.0 ),
214+ ).schema()
215+
216+ val scheme2 = dataFrameOf(
217+ " b" to columnOf(1.0 , 2.0 , 3.0 , 4.0 ),
218+ " a" to columnOf(1 , 2 , 3 , 4 ),
219+ ).schema()
220+
221+ scheme1.compare(scheme1a).matches() shouldBe true
222+ (scheme1 == scheme1a) shouldBe true
223+
224+ scheme1.compare(scheme2).matches() shouldBe true
225+ (scheme1 == scheme2) shouldBe false
226+ }
227+
228+ @Test
229+ fun `nested comparison with order` () {
230+ typed.schema().compare(typed.schema()).matches() shouldBe true
231+ (typed.schema() == typed.schema()) shouldBe true
232+
233+ val movedInGroup = typed.move { pageInfo.resultsPerPage }.after { pageInfo.snippets }
234+
235+ typed.schema().compare(movedInGroup.schema()).matches() shouldBe true
236+ (typed.schema() == movedInGroup.schema()) shouldBe false
237+
238+ val movedInFrameAndGroup = typed
239+ .update { items }.with {
240+ it.move { kind }.after { id }
241+ .move { snippet.position }.after { snippet.info }
242+ }
243+
244+ typed.schema().compare(movedInFrameAndGroup.schema()).matches() shouldBe true
245+ (typed.schema() == movedInFrameAndGroup.schema()) shouldBe false
246+ }
199247}
0 commit comments