Skip to content

Commit

Permalink
Simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Feb 19, 2023
1 parent eaea479 commit 214a0c7
Showing 1 changed file with 17 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,80 +13,36 @@ void matches() {
CompilationTestHelper.newInstance(MatcherTestChecker.class, getClass())
.addSourceLines(
"A.java",
"import com.google.common.base.Predicates;",
"import java.util.function.Function;",
"import java.util.stream.Stream;",
"import java.util.function.Predicate;",
"",
"class A {",
" Integer negative1() {",
" // BUG: Diagnostic contains:",
" Function<String, Integer> parseIntFunction = (String s) -> Integer.parseInt(s);",
" return Stream.of(\"1\")",
" .map(parseIntFunction)",
" // BUG: Diagnostic contains:",
" .reduce(0, Integer::sum);",
" }",
"",
" Integer negative2() {",
" // BUG: Diagnostic contains:",
" Function<String, Integer> stringLengthMethodReference = String::length;",
" return Stream.of(\"1\")",
" .map(stringLengthMethodReference)",
" // BUG: Diagnostic contains:",
" .reduce(0, Integer::sum);",
" boolean negative1() {",
" return true;",
" }",
"",
" Double negative3() {",
" Function<String, Double> parseDoubleFunction =",
" new Function<String, Double>() {",
" @Override",
" public Double apply(String s) {",
" return Double.parseDouble(s);",
" }",
" };",
" return Stream.of(\"1\")",
" .map(parseDoubleFunction)",
" // BUG: Diagnostic contains:",
" .reduce(0.0, Double::sum);",
" String negative2() {",
" return new String(new byte[0]);",
" }",
"",
" Long negative4() {",
" class ParseLongFunction implements Function<String, Long> {",
" @Override",
" public Long apply(String s) {",
" return Long.parseLong(s);",
" }",
" }",
" return Stream.of(\"1\")",
" .map(new ParseLongFunction())",
" // BUG: Diagnostic contains:",
" .reduce(0L, Long::sum);",
" Predicate<String> negative3() {",
" return Predicates.alwaysTrue();",
" }",
"",
" Integer positive1() {",
" return Stream.of(1)",
" // BUG: Diagnostic contains:",
" .map(i -> i * 2)",
" // BUG: Diagnostic contains:",
" .reduce(0, Integer::sum);",
" Predicate<String> positive1() {",
" // BUG: Diagnostic contains:",
" return str -> true;",
" }",
"",
" Long positive2() {",
" return Stream.of(1)",
" .map(",
" // BUG: Diagnostic contains:",
" i -> {",
" return i * 2L;",
" })",
" // BUG: Diagnostic contains:",
" .reduce(0L, Long::sum);",
" Predicate<String> positive2() {",
" // BUG: Diagnostic contains:",
" return String::isEmpty;",
" }",
"",
" Double positive3() {",
" return Stream.of(\"1\")",
" // BUG: Diagnostic contains:",
" .map(Double::parseDouble)",
" // BUG: Diagnostic contains:",
" .reduce(0.0, Double::sum);",
" Function<byte[], String> positive3() {",
" // BUG: Diagnostic contains:",
" return String::new;",
" }",
"}")
.doTest();
Expand Down

0 comments on commit 214a0c7

Please sign in to comment.