Skip to content

Commit 87bb0bc

Browse files
#103 add a test case
1 parent 05bf41a commit 87bb0bc

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package p;
2+
3+
import java.util.HashSet;
4+
import java.util.stream.*;
5+
6+
import edu.cuny.hunter.streamrefactoring.annotations.*;
7+
8+
class A {
9+
10+
Stream<Object> m() {
11+
Stream<Object> stream = new HashSet<>().stream().parallel();
12+
return stream;
13+
}
14+
15+
void n(Stream<Object> s) {
16+
s.distinct().count();
17+
}
18+
19+
@EntryPoint
20+
public void main(String[] args) {
21+
n(m());
22+
}
23+
}

edu.cuny.hunter.streamrefactoring.tests/test cases/edu/cuny/hunter/streamrefactoring/ui/tests/ConvertStreamToParallelRefactoringTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,15 @@ public void testNonInternalAPI5() throws Exception {
491491
RefactoringStatus.ERROR, EnumSet.of(PreconditionFailure.INCONSISTENT_POSSIBLE_EXECUTION_MODES)));
492492
}
493493

494+
public void testNonInternalAPI6() throws Exception {
495+
HashSet<ExecutionMode> executionModes = new HashSet<>();
496+
executionModes.add(ExecutionMode.PARALLEL);
497+
executionModes.add(ExecutionMode.SEQUENTIAL);
498+
helper(new StreamAnalysisExpectedResult("new HashSet<>().stream()", executionModes,
499+
Collections.singleton(Ordering.UNORDERED), false, true, false, null, null, null,
500+
RefactoringStatus.ERROR, EnumSet.of(PreconditionFailure.INCONSISTENT_POSSIBLE_EXECUTION_MODES)));
501+
}
502+
494503
public void testCollectionFromParameter() throws Exception {
495504
helper(new StreamAnalysisExpectedResult("h.parallelStream()", Collections.singleton(ExecutionMode.PARALLEL),
496505
Collections.singleton(Ordering.UNORDERED), false, true, false, null, null, null,

0 commit comments

Comments
 (0)