From bb90c5ad08cfe15d1f87171208cea237adbaf573 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Thu, 26 Oct 2017 13:57:58 +0300 Subject: [PATCH] Add tests for java stream chain building --- .../positive/location/AnonymousBody.kt | 9 +++++ .../positive/location/AssignExpression.kt | 5 +++ .../positive/location/BeforeStatement.kt | 5 +++ .../location/BetweenChainCallsAfterDot.kt | 20 ++++++++++ .../location/BetweenChainCallsBeforeDot.kt | 5 +++ .../location/BetweenParametersAfterComma.kt | 5 +++ .../location/BetweenParametersBeforeComma.kt | 5 +++ .../location/FirstParameterOfFunction.kt | 7 ++++ .../positive/location/InAnyAnonymous.kt | 10 +++++ .../streams/positive/location/InAnyLambda.kt | 8 ++++ .../positive/location/InEmptyParameterList.kt | 5 +++ .../positive/location/InMethodReference.kt | 5 +++ .../psi/streams/positive/location/InString.kt | 5 +++ .../positive/location/InVariableName.kt | 11 ++++++ .../streams/positive/location/LambdaBody.kt | 5 +++ .../location/ParameterInAssignExpression.kt | 14 +++++++ .../location/ParameterInReturnExpression.kt | 13 +++++++ .../positive/location/ReturnExpression.kt | 9 +++++ .../location/SecondParameterOfFunction.kt | 9 +++++ .../positive/location/SingleExpression.kt | 5 +++ .../psi/java/LocationPositiveChainTest.kt | 38 +++++++++++++++++++ 21 files changed, 198 insertions(+) create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/AnonymousBody.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/AssignExpression.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/BeforeStatement.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsAfterDot.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsBeforeDot.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersAfterComma.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersBeforeComma.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/FirstParameterOfFunction.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/InAnyAnonymous.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/InAnyLambda.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/InEmptyParameterList.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/InMethodReference.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/InString.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/InVariableName.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/LambdaBody.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInAssignExpression.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInReturnExpression.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/ReturnExpression.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/SecondParameterOfFunction.kt create mode 100644 idea/testData/debugger/sequence/psi/streams/positive/location/SingleExpression.kt create mode 100644 idea/tests/com/intellij/debugger/streams/kotlin/psi/java/LocationPositiveChainTest.kt diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/AnonymousBody.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/AnonymousBody.kt new file mode 100644 index 00000000000..91bde01303d --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/AnonymousBody.kt @@ -0,0 +1,9 @@ +import java.util.stream.Stream + +fun main(args: Array) { + object : Runnable { + override fun run() { + Stream.of(1, 2, 3).forEach { x -> } + } + }.run() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/AssignExpression.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/AssignExpression.kt new file mode 100644 index 00000000000..64b8203511b --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/AssignExpression.kt @@ -0,0 +1,5 @@ +import java.util.stream.IntStream + +fun main(args: Array) { + val res = IntStream.of(1, 2).sum() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/BeforeStatement.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/BeforeStatement.kt new file mode 100644 index 00000000000..dc192733c11 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/BeforeStatement.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsAfterDot.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsAfterDot.kt new file mode 100644 index 00000000000..f2b36b4c22c --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsAfterDot.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.util.stream.Stream + +fun main(args: Array) { + Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x!! % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsBeforeDot.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsBeforeDot.kt new file mode 100644 index 00000000000..180b7b28ca2 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenChainCallsBeforeDot.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersAfterComma.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersAfterComma.kt new file mode 100644 index 00000000000..b3de8af648d --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersAfterComma.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersBeforeComma.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersBeforeComma.kt new file mode 100644 index 00000000000..131698d5f8b --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/BetweenParametersBeforeComma.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x!! % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/FirstParameterOfFunction.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/FirstParameterOfFunction.kt new file mode 100644 index 00000000000..a70b859a716 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/FirstParameterOfFunction.kt @@ -0,0 +1,7 @@ +import java.util.stream.IntStream + +fun foo(bar: Int) {} + +fun main(args: Array) { + foo(IntStream.of(1, 2, 3).sum()) +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/InAnyAnonymous.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/InAnyAnonymous.kt new file mode 100644 index 00000000000..93c00de74b7 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/InAnyAnonymous.kt @@ -0,0 +1,10 @@ +import java.util.function.Consumer +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.peek(object : Consumer { + override fun accept(x: Int) { + println(x) + } + }).count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/InAnyLambda.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/InAnyLambda.kt new file mode 100644 index 00000000000..0c7f2e6687b --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/InAnyLambda.kt @@ -0,0 +1,8 @@ +import java.util.stream.Stream + +object Bar { + @JvmStatic + fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.count() + } +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/InEmptyParameterList.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/InEmptyParameterList.kt new file mode 100644 index 00000000000..42de490c35f --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/InEmptyParameterList.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/InMethodReference.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/InMethodReference.kt new file mode 100644 index 00000000000..37213d8c1a0 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/InMethodReference.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map(String::length).filter { x -> x!! % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/InString.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/InString.kt new file mode 100644 index 00000000000..a660914fd4b --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/InString.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + val count = Stream.of("abc", "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/InVariableName.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/InVariableName.kt new file mode 100644 index 00000000000..73c8e743383 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/InVariableName.kt @@ -0,0 +1,11 @@ +import java.util.function.Consumer +import java.util.stream.Stream + +fun main(args: Array) { + val `var` = "abd" + val count = Stream.of(`var`, "acd", "ef").map({ it.length }).filter { x -> x % 2 == 0 }.peek(object : Consumer { + override fun accept(x: Int) { + println(x) + } + }).count() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/LambdaBody.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/LambdaBody.kt new file mode 100644 index 00000000000..8957e982683 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/LambdaBody.kt @@ -0,0 +1,5 @@ +import java.util.stream.Stream + +fun main(args: Array) { + ({ Stream.of(1, 2, 3).forEach { x -> } } as Runnable).run() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInAssignExpression.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInAssignExpression.kt new file mode 100644 index 00000000000..521285152cc --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInAssignExpression.kt @@ -0,0 +1,14 @@ +import java.util.stream.IntStream + +internal fun bar2(a: Int, b: Int, c: Int): Int { + return 0 +} + +internal fun foo2(): Int { + val result = bar2(0, 1, c = IntStream.range(1, 2).sum()) + return result +} + +fun main(args: Array) { + foo2() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInReturnExpression.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInReturnExpression.kt new file mode 100644 index 00000000000..aff02dec228 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/ParameterInReturnExpression.kt @@ -0,0 +1,13 @@ +import java.util.stream.IntStream + +internal fun bar1(a: Int, b: Int, c: Int): Int { + return 0 +} + +internal fun foo1(): Int { + return bar1(0, 1, c = IntStream.range(1, 2).sum()) +} + +fun main(args: Array) { + foo1() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/ReturnExpression.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/ReturnExpression.kt new file mode 100644 index 00000000000..12fbcf44e9c --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/ReturnExpression.kt @@ -0,0 +1,9 @@ +import java.util.stream.IntStream + +fun foo(): Int { + return IntStream.range(1, 2).sum() +} + +fun main(args: Array) { + foo() +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/SecondParameterOfFunction.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/SecondParameterOfFunction.kt new file mode 100644 index 00000000000..ff62f714212 --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/SecondParameterOfFunction.kt @@ -0,0 +1,9 @@ +import java.util.stream.IntStream + +fun foo(baz: Int, bar: Int): Int { + return IntStream.range(1, 2).sum() +} + +fun main(args: Array) { + foo(0, IntStream.of(1, 2, 3).sum()) +} diff --git a/idea/testData/debugger/sequence/psi/streams/positive/location/SingleExpression.kt b/idea/testData/debugger/sequence/psi/streams/positive/location/SingleExpression.kt new file mode 100644 index 00000000000..b2846b903ff --- /dev/null +++ b/idea/testData/debugger/sequence/psi/streams/positive/location/SingleExpression.kt @@ -0,0 +1,5 @@ +import java.util.stream.IntStream + +fun main(args: Array) { + IntStream.range(1, 2).forEach { x -> } +} diff --git a/idea/tests/com/intellij/debugger/streams/kotlin/psi/java/LocationPositiveChainTest.kt b/idea/tests/com/intellij/debugger/streams/kotlin/psi/java/LocationPositiveChainTest.kt new file mode 100644 index 00000000000..af53459a97f --- /dev/null +++ b/idea/tests/com/intellij/debugger/streams/kotlin/psi/java/LocationPositiveChainTest.kt @@ -0,0 +1,38 @@ +package com.intellij.debugger.streams.kotlin.psi.java + +/** + * @author Vitaliy.Bibaev + */ +class LocationPositiveChainTest : PositiveJavaStreamTest("location") { + fun testAnonymousBody() = doTest() + + fun testAssignExpression() = doTest() + + fun testFirstParameterOfFunction() = doTest() + fun testLambdaBody() = doTest() + + fun testParameterInAssignExpression() = doTest() + fun testParameterInReturnExpression() = doTest() + + fun testReturnExpression() = doTest() + + fun testSecondParameterOfFunction() = doTest() + + fun testSingleExpression() = doTest() + + fun testBeforeStatement() = doTest() + + fun testBetweenChainCallsBeforeDot() = doTest() + fun testBetweenChainCallsAfterDot() = doTest() + + fun testInEmptyParameterList() = doTest() + + fun testBetweenParametersBeforeComma() = doTest() + fun testBetweenParametersAfterComma() = doTest() + + fun testInAnyLambda() = doTest() + fun testInAnyAnonymous() = doTest() + fun testInString() = doTest() + fun testInVariableName() = doTest() + fun testInMethodReference() = doTest() +} \ No newline at end of file