Checker.java

1
package com.github.dakusui.pcond.core.fluent;
2
3
import com.github.dakusui.pcond.fluent.Statement;
4
5
import java.util.function.Function;
6
import java.util.function.Predicate;
7
import java.util.function.Supplier;
8
9
import static java.util.Objects.requireNonNull;
10
11
public interface Checker<
12
    V extends Checker<V, T, R>,
13
    T,
14
    R> extends
15
    Matcher<V, T, R>,
16
    Statement<T> {
17
  V addCheckPhrase(Function<Checker<?, R, R>, Predicate<R>> clause);
18
19
  @SuppressWarnings("unchecked")
20
  default V checkWithPredicate(Predicate<? super R> predicate) {
21
    requireNonNull(predicate);
22 2 1. checkWithPredicate : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::checkWithPredicate → KILLED
2. lambda$checkWithPredicate$0 : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::lambda$checkWithPredicate$0 → KILLED
    return addCheckPhrase(w -> (Predicate<R>) predicate);
23
  }
24
25
  default V predicate(Predicate<? super R> predicate) {
26 1 1. predicate : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::predicate → KILLED
    return checkWithPredicate(predicate);
27
  }
28
29
  default Predicate<T> done() {
30 1 1. done : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::done → KILLED
    return statementPredicate();
31
  }
32
33
  /**
34
   * // @formatter:off
35
   * When you use an assertion method that accepts multiple statements (`Statement`), it requires all the elements in the array (`varargs`) should have the same generic parameter type.
36
   * However, you sometimes want to check multiple types at once.
37
   * By calling this method for every statement building method calling chain, you can address the compilation error.
38
   *
39
   * [source, java]
40
   * ```
41
   * class Example {
42
   *   public static void main(String... args) {
43
   *     assert all(
44
   *        objectValue(arg[0]).isNotNull().$(),
45
   *        objectValue(new Example()).isNotNull().$(),
46
   *        ...
47
   *   }
48
   * }
49
   * ```
50
   *
51
   * // @formatter.off
52
   *
53
   * @return A statement for `java.lang.Object` type.
54
   */
55
  @SuppressWarnings("unchecked")
56
  default Statement<Object> $() {
57 1 1. $ : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::$ → KILLED
    return (Statement<Object>) this;
58
  }
59
60
  abstract class Base<
61
      V extends Checker<V, T, R>,
62
      T,
63
      R> extends
64
      Matcher.Base<
65
          V,
66
          T,
67
          R
68
          > implements
69
      Checker<
70
          V,
71
          T,
72
          R> {
73
    public Base(Supplier<T> baseValue, Function<T, R> transformFunction) {
74
      super(baseValue, transformFunction);
75
    }
76
77
    @SuppressWarnings("unchecked")
78
    @Override
79
    public V addCheckPhrase(Function<Checker<?, R, R>, Predicate<R>> clause) {
80 2 1. addCheckPhrase : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::addCheckPhrase → KILLED
2. lambda$addCheckPhrase$0 : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::lambda$addCheckPhrase$0 → KILLED
      return this.addPredicate((Matcher<?, R, R> v) -> clause.apply((Checker<?, R, R>) v));
81
    }
82
83
    @Override
84
    public T statementValue() {
85 1 1. statementValue : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::statementValue → KILLED
      return this.baseValue();
86
    }
87
88
    @Override
89
    public Predicate<T> statementPredicate() {
90 1 1. statementPredicate : replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::statementPredicate → KILLED
      return toPredicate();
91
    }
92
  }
93
}

Mutations

22

1.1
Location : checkWithPredicate
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest.test_isEmpty(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::checkWithPredicate → KILLED

2.2
Location : lambda$checkWithPredicate$0
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest.test_isEmpty(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::lambda$checkWithPredicate$0 → KILLED

26

1.1
Location : predicate
Killed by : com.github.dakusui.ut.valid8j.ut.styles.FluentStyleDbCTest$ForRequiresTest.requireArgumentsTest_failing(com.github.dakusui.ut.valid8j.ut.styles.FluentStyleDbCTest$ForRequiresTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::predicate → KILLED

30

1.1
Location : done
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::done → KILLED

57

1.1
Location : $
Killed by : com.github.dakusui.ut.thincrest.ut.styles.FluentStyleTestAssertionTest$ForTestAssertionsTest.assertAllDifferentTypes_passed(com.github.dakusui.ut.thincrest.ut.styles.FluentStyleTestAssertionTest$ForTestAssertionsTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker::$ → KILLED

80

1.1
Location : addCheckPhrase
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest.test_isEmpty(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::addCheckPhrase → KILLED

2.2
Location : lambda$addCheckPhrase$0
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest.test_isEmpty(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::lambda$addCheckPhrase$0 → KILLED

85

1.1
Location : statementValue
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest.test_isEmpty(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::statementValue → KILLED

90

1.1
Location : statementPredicate
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest.test_isEmpty(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentStringTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/Checker$Base::statementPredicate → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3