From d30a3b2495dcc89e0d9afc332d847c9a80c75d55 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Thu, 21 Dec 2017 11:44:40 +0300 Subject: [PATCH] Add tests for distinct operations --- .../sequence/exec/sequence/outs/distinct.out | 39 +++++++++++++++++++ .../exec/sequence/outs/distinctBy.out | 10 +++++ .../exec/sequence/outs/distinctObjects.out | 34 ++++++++++++++++ .../exec/sequence/src/distinct/Distinct.kt | 6 +++ .../exec/sequence/src/distinct/DistinctBy.kt | 6 +++ .../sequence/src/distinct/DistinctObjects.kt | 7 ++++ .../exec/sequence/DistinctOperationsTest.kt | 11 ++++++ 7 files changed, 113 insertions(+) create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/distinct.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/distinctBy.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/outs/distinctObjects.out create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/distinct/Distinct.kt create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctBy.kt create mode 100644 idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctObjects.kt create mode 100644 idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/DistinctOperationsTest.kt diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/distinct.out b/idea/testData/debugger/sequence/exec/sequence/outs/distinct.out new file mode 100644 index 00000000000..5ed531b0a9f --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/distinct.out @@ -0,0 +1,39 @@ +LineBreakpoint created at Distinct.kt:5 +Run Java +Connected to the target VM +Distinct.kt:5 +listOf(1, 2, 3, 2, 1, 3, 4, 2).asSequence() +.distinct() +.count() +distinct + before: 1,3,5,7,8,9,10,12 + after: 2,4,6,11 +count + before: 2,4,6,11 + after: nothing +mappings for distinct + direct: + 1 -> 2 + 3 -> 4 + 5 -> 6 + 7 -> 4 + 8 -> 2 + 9 -> 6 + 10 -> 11 + 12 -> 4 + reverse: + 1,8 <- 2 + 3,7,12 <- 4 + 5,9 <- 6 + 10 <- 11 +mappings for count + direct: + 2 -> nothing + 4 -> nothing + 6 -> nothing + 11 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/distinctBy.out b/idea/testData/debugger/sequence/exec/sequence/outs/distinctBy.out new file mode 100644 index 00000000000..7641e6d78a6 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/distinctBy.out @@ -0,0 +1,10 @@ +LineBreakpoint created at DistinctBy.kt:5 +Run Java +Connected to the target VM +DistinctBy.kt:5 +Exception caught: junit.framework.AssertionFailedError: Unresolved reference: andThen, Unresolved reference: andThen +Disconnected from the target VM + +WRONG! Should be fixed in the platform + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/outs/distinctObjects.out b/idea/testData/debugger/sequence/exec/sequence/outs/distinctObjects.out new file mode 100644 index 00000000000..42bc9fb6764 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/outs/distinctObjects.out @@ -0,0 +1,34 @@ +LineBreakpoint created at DistinctObjects.kt:6 +Run Java +Connected to the target VM +DistinctObjects.kt:6 +listOf(str('a'), str('b'), str('a'), str('c'), str('b')).asSequence() +.distinct() +.count() +distinct + before: 1,3,5,6,8 + after: 2,4,7 +count + before: 2,4,7 + after: nothing +mappings for distinct + direct: + 1 -> 2 + 3 -> 4 + 5 -> 2 + 6 -> 7 + 8 -> 4 + reverse: + 1,5 <- 2 + 3,8 <- 4 + 6 <- 7 +mappings for count + direct: + 2 -> nothing + 4 -> nothing + 7 -> nothing + reverse: + empty +Disconnected from the target VM + +Process finished with exit code 0 diff --git a/idea/testData/debugger/sequence/exec/sequence/src/distinct/Distinct.kt b/idea/testData/debugger/sequence/exec/sequence/src/distinct/Distinct.kt new file mode 100644 index 00000000000..57b999aa2bb --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/distinct/Distinct.kt @@ -0,0 +1,6 @@ +package distinct + +fun main(args: Array) { + // Breakpoint! + listOf(1, 2, 3, 2, 1, 3, 4, 2).asSequence().distinct().count() +} \ No newline at end of file diff --git a/idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctBy.kt b/idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctBy.kt new file mode 100644 index 00000000000..29fcb824771 --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctBy.kt @@ -0,0 +1,6 @@ +package distinct + +fun main(args: Array) { + // Breakpoint! + listOf(3, 4, 234, 34, 54, 23, 4, 23, 543, 5, 46).asSequence().distinctBy { it % 10 }.toList() +} \ No newline at end of file diff --git a/idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctObjects.kt b/idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctObjects.kt new file mode 100644 index 00000000000..f771b5aac0a --- /dev/null +++ b/idea/testData/debugger/sequence/exec/sequence/src/distinct/DistinctObjects.kt @@ -0,0 +1,7 @@ +package distinct + +fun main(args: Array) { + fun str(chr: Char): String = String(charArrayOf(chr)) + // Breakpoint! + listOf(str('a'), str('b'), str('a'), str('c'), str('b')).asSequence().distinct().count() +} \ No newline at end of file diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/DistinctOperationsTest.kt b/idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/DistinctOperationsTest.kt new file mode 100644 index 00000000000..6bdd5080589 --- /dev/null +++ b/idea/tests/com/intellij/debugger/streams/kotlin/exec/sequence/DistinctOperationsTest.kt @@ -0,0 +1,11 @@ +// 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 DistinctOperationsTest : OperationsTestCase("distinct") { + fun testDistinct() = doTestWithResult() + fun testDistinctObjects() = doTestWithResult() + fun testDistinctBy() = doTestWithResult() +} \ No newline at end of file