From fd17d9959a867fc6907297eda631f93aee068a56 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Thu, 21 Dec 2017 11:08:18 +0300 Subject: [PATCH] Add tests for sorting operations --- .../sequence/exec/sequence/outs/sorted.out | 32 +++++++++++++++++++ .../sequence/exec/sequence/outs/sortedBy.out | 29 +++++++++++++++++ .../exec/sequence/outs/sortedByDescending.out | 29 +++++++++++++++++ .../exec/sequence/outs/sortedDescending.out | 32 +++++++++++++++++++ .../exec/sequence/outs/sortedWith.out | 29 +++++++++++++++++ .../sequence/exec/sequence/src/sort/Sorted.kt | 6 ++++ .../exec/sequence/src/sort/SortedBy.kt | 9 ++++++ .../sequence/src/sort/SortedByDescending.kt | 6 ++++ .../sequence/src/sort/SortedDescending.kt | 6 ++++ .../exec/sequence/src/sort/SortedWith.kt | 7 ++++ .../exec/sequence/SortingOperationsTest.kt | 13 ++++++++ 11 files changed, 198 insertions(+) create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/sorted.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/sortedBy.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/sortedByDescending.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/sortedDescending.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/sortedWith.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/sort/Sorted.kt create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/sort/SortedBy.kt create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/sort/SortedByDescending.kt create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/sort/SortedDescending.kt create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/sort/SortedWith.kt create mode 100644 idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/SortingOperationsTest.kt diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/sorted.out b/idea/testData/debugger/sequence/exec/sequence/outs/sorted.out new file mode 100644 index 00000000000..51ececc5f69 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/sorted.out @@ -0,0 +1,32 @@ +LineBreakpoint created at Sorted.kt:5 +Run Java +Connected to the target VM +Sorted.kt:5 +intArrayOf(2, 1, 3).asSequence() +.sorted() +.toList() +sorted + before: 1,2,3 + after: 4,5,6 +toList + before: 4,5,6 + after: nothing +mappings for sorted + direct: + 1 -> 5 + 2 -> 4 + 3 -> 6 + reverse: + 2 <- 4 + 1 <- 5 + 3 <- 6 +mappings for toList + direct: + 4 -> nothing + 5 -> nothing + 6 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/sortedBy.out b/idea/testData/debugger/sequence/exec/sequence/outs/sortedBy.out new file mode 100644 index 00000000000..151eae256f5 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/sortedBy.out @@ -0,0 +1,29 @@ +LineBreakpoint created at SortedBy.kt:6 +Run Java +Connected to the target VM +SortedBy.kt:6 +arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence() +.sortedBy({ it.age }) +.count() +sortedBy + before: 1,2 + after: 3,4 +count + before: 3,4 + after: nothing +mappings for sortedBy + direct: + 1 -> 4 + 2 -> 3 + reverse: + 2 <- 3 + 1 <- 4 +mappings for count + direct: + 3 -> nothing + 4 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/sortedByDescending.out b/idea/testData/debugger/sequence/exec/sequence/outs/sortedByDescending.out new file mode 100644 index 00000000000..415116b4c44 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/sortedByDescending.out @@ -0,0 +1,29 @@ +LineBreakpoint created at SortedByDescending.kt:5 +Run Java +Connected to the target VM +SortedByDescending.kt:5 +arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence() +.sortedByDescending({ it.age }) +.count() +sortedByDescending + before: 1,2 + after: 3,4 +count + before: 3,4 + after: nothing +mappings for sortedByDescending + direct: + 1 -> nothing + 2 -> nothing + reverse: + nothing <- 3 + nothing <- 4 +mappings for count + direct: + 3 -> nothing + 4 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/sortedDescending.out b/idea/testData/debugger/sequence/exec/sequence/outs/sortedDescending.out new file mode 100644 index 00000000000..da659040fd6 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/sortedDescending.out @@ -0,0 +1,32 @@ +LineBreakpoint created at SortedDescending.kt:5 +Run Java +Connected to the target VM +SortedDescending.kt:5 +intArrayOf(2, 1, 3).asSequence() +.sortedDescending() +.toList() +sortedDescending + before: 1,2,3 + after: 4,5,6 +toList + before: 4,5,6 + after: nothing +mappings for sortedDescending + direct: + 1 -> 5 + 2 -> 6 + 3 -> 4 + reverse: + 3 <- 4 + 1 <- 5 + 2 <- 6 +mappings for toList + direct: + 4 -> nothing + 5 -> nothing + 6 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/sortedWith.out b/idea/testData/debugger/sequence/exec/sequence/outs/sortedWith.out new file mode 100644 index 00000000000..7853461594a --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/sortedWith.out @@ -0,0 +1,29 @@ +LineBreakpoint created at SortedWith.kt:5 +Run Java +Connected to the target VM +SortedWith.kt:5 +arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence() +.sortedWith(compareBy { it.name }) +.count() +sortedWith + before: 1,2 + after: 3,4 +count + before: 3,4 + after: nothing +mappings for sortedWith + direct: + 1 -> 4 + 2 -> 3 + reverse: + 2 <- 3 + 1 <- 4 +mappings for count + direct: + 3 -> nothing + 4 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/src/sort/Sorted.kt b/idea/testData/debugger/sequence/exec/sequence/src/sort/Sorted.kt new file mode 100644 index 00000000000..c721ad1149f --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/sort/Sorted.kt @@ -0,0 +1,6 @@ +package sort + +fun main(args: Array) { + // Breakpoint! + intArrayOf(2, 1, 3).asSequence().sorted().toList() +} \ No newline at end of file diff --git a/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedBy.kt b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedBy.kt new file mode 100644 index 00000000000..d7531718e0c --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedBy.kt @@ -0,0 +1,9 @@ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package sort + +fun main(args: Array) { + // Breakpoint! + arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence().sortedBy { it.age }.count() +} + +internal data class Person(val name: String, val age: Int) \ No newline at end of file diff --git a/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedByDescending.kt b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedByDescending.kt new file mode 100644 index 00000000000..447e6969552 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedByDescending.kt @@ -0,0 +1,6 @@ +package sort + +fun main(args: Array) { + // Breakpoint! + arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence().sortedByDescending { it.age }.count() +} \ No newline at end of file diff --git a/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedDescending.kt b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedDescending.kt new file mode 100644 index 00000000000..ce3c456ead7 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedDescending.kt @@ -0,0 +1,6 @@ +package sort + +fun main(args: Array) { + // Breakpoint! + intArrayOf(2, 1, 3).asSequence().sortedDescending().toList() +} \ No newline at end of file diff --git a/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedWith.kt b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedWith.kt new file mode 100644 index 00000000000..0e9f3460261 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/sort/SortedWith.kt @@ -0,0 +1,7 @@ +package sort + +fun main(args: Array) { + // Breakpoint! + arrayOf(Person("Bob", 42), Person("Alice", 27)).asSequence() + .sortedWith(compareBy { it.name }).count() +} \ No newline at end of file diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/SortingOperationsTest.kt b/idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/SortingOperationsTest.kt new file mode 100644 index 00000000000..c293139ae3f --- /dev/null +++ b/idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/SortingOperationsTest.kt @@ -0,0 +1,13 @@ +// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.debugger.streams.kotlin.exec.sequence + +/** + * @author Vitaliy.Bibaev + */ +class SortingOperationsTest : OperationsTestCase("sort") { + fun testSorted() = doTestWithResult() + fun testSortedBy() = doTestWithResult() + fun testSortedDescending() = doTestWithResult() + fun testSortedByDescending() = doTestWithResult() + fun testSortedWith() = doTestWithResult() +} \ No newline at end of file