| 1 | package com.github.dakusui.pcond.core.printable; | |
| 2 | ||
| 3 | import com.github.dakusui.pcond.core.Evaluable; | |
| 4 | import com.github.dakusui.pcond.core.Evaluator; | |
| 5 | ||
| 6 | import java.util.Objects; | |
| 7 | import java.util.function.Predicate; | |
| 8 | import java.util.function.Supplier; | |
| 9 | ||
| 10 | import static com.github.dakusui.pcond.internals.InternalUtils.formatObject; | |
| 11 | import static com.github.dakusui.pcond.internals.InternalUtils.toNonStringObject; | |
| 12 | import static java.util.Collections.emptyList; | |
| 13 | ||
| 14 | public abstract class ExplainablePredicate<V> extends PrintablePredicate<V> | |
| 15 | implements Predicate<V>, Evaluable.LeafPred<V>, Evaluator.Explainable { | |
| 16 | V actualInput; | |
| 17 | ||
| 18 | protected ExplainablePredicate(Supplier<String> formatter, Predicate<? super V> predicate) { | |
| 19 | super(new Object(), emptyList(), formatter, predicate); | |
| 20 | } | |
| 21 | ||
| 22 | @Override | |
| 23 | public boolean test(V value) { | |
| 24 | actualInput = value; | |
| 25 |
2
1. test : replaced boolean return with false for com/github/dakusui/pcond/core/printable/ExplainablePredicate::test → NO_COVERAGE 2. test : replaced boolean return with true for com/github/dakusui/pcond/core/printable/ExplainablePredicate::test → NO_COVERAGE |
return super.test(value); |
| 26 | } | |
| 27 | ||
| 28 | protected V actualInput() { | |
| 29 |
1
1. actualInput : replaced return value with null for com/github/dakusui/pcond/core/printable/ExplainablePredicate::actualInput → SURVIVED |
return this.actualInput; |
| 30 | } | |
| 31 | ||
| 32 | @Override | |
| 33 | public Object explainActual(Object actualValue) { | |
| 34 |
1
1. explainActual : replaced return value with null for com/github/dakusui/pcond/core/printable/ExplainablePredicate::explainActual → SURVIVED |
return actualInput(); |
| 35 | } | |
| 36 | ||
| 37 | @Override | |
| 38 | public Predicate<? super V> predicate() { | |
| 39 |
1
1. predicate : replaced return value with null for com/github/dakusui/pcond/core/printable/ExplainablePredicate::predicate → KILLED |
return (Predicate<V>) v -> { |
| 40 | actualInput = v; | |
| 41 |
2
1. lambda$predicate$0 : replaced boolean return with false for com/github/dakusui/pcond/core/printable/ExplainablePredicate::lambda$predicate$0 → KILLED 2. lambda$predicate$0 : replaced boolean return with true for com/github/dakusui/pcond/core/printable/ExplainablePredicate::lambda$predicate$0 → KILLED |
return super.predicate.test(v); |
| 42 | }; | |
| 43 | } | |
| 44 | ||
| 45 | public static Predicate<String> explainableStringIsEqualTo(String str) { | |
| 46 |
4
1. explainableStringIsEqualTo : replaced return value with null for com/github/dakusui/pcond/core/printable/ExplainablePredicate::explainableStringIsEqualTo → KILLED 2. lambda$explainableStringIsEqualTo$1 : replaced return value with "" for com/github/dakusui/pcond/core/printable/ExplainablePredicate::lambda$explainableStringIsEqualTo$1 → KILLED 3. lambda$explainableStringIsEqualTo$2 : replaced boolean return with false for com/github/dakusui/pcond/core/printable/ExplainablePredicate::lambda$explainableStringIsEqualTo$2 → KILLED 4. lambda$explainableStringIsEqualTo$2 : replaced boolean return with true for com/github/dakusui/pcond/core/printable/ExplainablePredicate::lambda$explainableStringIsEqualTo$2 → KILLED |
return new ExplainablePredicate<String>(() -> "stringIsEqualTo[" + formatObject(toNonStringObject(str)) + "]", v -> Objects.equals(str, v)) { |
| 47 | @Override | |
| 48 | public Object explainOutputExpectation() { | |
| 49 |
1
1. explainOutputExpectation : replaced return value with null for com/github/dakusui/pcond/core/printable/ExplainablePredicate$1::explainOutputExpectation → SURVIVED |
return str; |
| 50 | } | |
| 51 | }; | |
| 52 | } | |
| 53 | } | |
Mutations | ||
| 25 |
1.1 2.2 |
|
| 29 |
1.1 |
|
| 34 |
1.1 |
|
| 39 |
1.1 |
|
| 41 |
1.1 2.2 |
|
| 46 |
1.1 2.2 3.3 4.4 |
|
| 49 |
1.1 |