| 1 | package com.github.valid8j.pcond.core; | |
| 2 | ||
| 3 | import com.github.valid8j.pcond.core.ValueHolder.State; | |
| 4 | import com.github.valid8j.pcond.validator.Validator; | |
| 5 | ||
| 6 | import java.util.Arrays; | |
| 7 | import java.util.List; | |
| 8 | import java.util.Objects; | |
| 9 | import java.util.concurrent.atomic.AtomicReference; | |
| 10 | ||
| 11 | import static com.github.valid8j.pcond.core.EvaluationContext.resolveEvaluationEntryType; | |
| 12 | import static com.github.valid8j.pcond.core.Evaluator.Explainable.*; | |
| 13 | import static com.github.valid8j.pcond.core.Evaluator.Impl.EVALUATION_SKIPPED; | |
| 14 | import static com.github.valid8j.pcond.core.Evaluator.Snapshottable.toSnapshotIfPossible; | |
| 15 | import static com.github.valid8j.pcond.core.ValueHolder.CreatorFormType.FUNC_TAIL; | |
| 16 | import static com.github.valid8j.pcond.core.ValueHolder.State.VALUE_RETURNED; | |
| 17 | import static java.lang.String.format; | |
| 18 | import static java.util.Arrays.asList; | |
| 19 | import static java.util.stream.Collectors.joining; | |
| 20 | import static java.util.stream.Collectors.toList; | |
| 21 | import static com.github.valid8j.pcond.core.EvaluationEntry.Type.*; | |
| 22 | ||
| 23 | /** | |
| 24 | * | |
| 25 | * // @formatter:off | |
| 26 | * A class to hold an entry of execution history of the {@link Evaluator}. | |
| 27 | * When an evaluator enters into one {@link Evaluable} (actually a predicate or a function), | |
| 28 | * an {@code OnGoing} entry is created and held by the evaluator as a current | |
| 29 | * one. | |
| 30 | * Since one evaluate can have its children and only one child can be evaluated at once, | |
| 31 | * on-going entries are held as a list (stack). | |
| 32 | * | |
| 33 | * When the evaluator leaves the evaluable, the entry is "finalized". | |
| 34 | * From the data held by an entry, "expectation" and "actual behavior" reports are generated. | |
| 35 | * | |
| 36 | * .Evaluation Summary Format | |
| 37 | * ---- | |
| 38 | * | |
| 39 | * +----------------------------------------------------------------------------- Failure Detail Index | |
| 40 | * | +-------------------------------------------------------------------------- Input | |
| 41 | * | | +----------------------------- Form (Function/Predicate) | |
| 42 | * | | | +- Output | |
| 43 | * | | | | | |
| 44 | * V V V V | |
| 45 | * Book:[title:<De Bello G...i appellantur.>]->check:allOf ->false | |
| 46 | * transform:title ->"De Bello Gallico" | |
| 47 | * "De Bello Gallico" -> check:allOf ->false | |
| 48 | * isNotNull ->true | |
| 49 | * [0] transform:parseInt->NumberFormatException:"For input s...ico"" | |
| 50 | * null -> check:allOf ->false | |
| 51 | * >=[10] ->true | |
| 52 | * <[40] ->true | |
| 53 | * Book:[title:<De Bello G...i appellantur.>]-> transform:title ->"Gallia est omnis divis...li appellantur." | |
| 54 | * "Gallia est omnis divis...li appellantur."-> check:allOf ->false | |
| 55 | * isNotNull ->true | |
| 56 | * transform:length ->145 | |
| 57 | * 145 -> check:allOf ->false | |
| 58 | * [1] >=[200] ->true | |
| 59 | * <[400] ->true | |
| 60 | * | |
| 61 | * ---- | |
| 62 | * | |
| 63 | * Failure Detail Index:: | |
| 64 | * In the full format of a failure report, detailed descriptions of mismatching forms are provided if the form is {@link Evaluator.Explainable}. | |
| 65 | * This index points an item in the detail part of the full report. | |
| 66 | * Input:: | |
| 67 | * Values given to forms are printed here. | |
| 68 | * If the previous line uses the same value, the value will not be printed. | |
| 69 | * Form (Function/Predicate):: | |
| 70 | * This part displays names of forms (predicates and functions). | |
| 71 | * If a form is marked trivial, the framework may merge the form with the next line. | |
| 72 | * Output:: | |
| 73 | * For predicates, expected boolean value is printed. | |
| 74 | * For functions, if a function does not throw an exception during its evaluation, the result will be printed here both for expectation and actual behavior summary. | |
| 75 | * If it throws an exception, the exception will be printed here in actual behavior summary. | |
| 76 | * | |
| 77 | * // @formatter:on | |
| 78 | */ | |
| 79 | public abstract class EvaluationEntry { | |
| 80 | private final Type type; | |
| 81 | /** | |
| 82 | * A name of a form (evaluable; function, predicate) | |
| 83 | */ | |
| 84 | private final String formName; | |
| 85 | private final boolean trivial; | |
| 86 | int level; | |
| 87 | ||
| 88 | Object inputExpectation; | |
| 89 | Object detailInputExpectation; | |
| 90 | ||
| 91 | Object inputActualValue; | |
| 92 | Object detailInputActualValue; | |
| 93 | ||
| 94 | Object outputExpectation; | |
| 95 | Object detailOutputExpectation; | |
| 96 | ||
| 97 | ||
| 98 | /** | |
| 99 | * A flag to let the framework know this entry should be printed in a less outstanding form. | |
| 100 | */ | |
| 101 | final boolean squashable; | |
| 102 | ||
| 103 | EvaluationEntry(String formName, Type type, int level, Object inputExpectation_, Object detailInputExpectation_, Object outputExpectation, Object detailOutputExpectation, Object inputActualValue, Object detailInputActualValue, boolean squashable, boolean trivial) { | |
| 104 | this.type = type; | |
| 105 | this.level = level; | |
| 106 | this.formName = formName; | |
| 107 | this.inputExpectation = inputExpectation_; | |
| 108 | this.detailInputExpectation = detailInputExpectation_; | |
| 109 | this.outputExpectation = outputExpectation; | |
| 110 | this.detailOutputExpectation = detailOutputExpectation; | |
| 111 | this.inputActualValue = inputActualValue; | |
| 112 | this.detailInputActualValue = detailInputActualValue; | |
| 113 | this.squashable = squashable; | |
| 114 | this.trivial = trivial; | |
| 115 | } | |
| 116 | ||
| 117 | public String formName() { | |
| 118 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry::formName → KILLED |
return formName; |
| 119 | } | |
| 120 | ||
| 121 | public Type type() { | |
| 122 |
1
1. type : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::type → KILLED |
return this.type; |
| 123 | } | |
| 124 | ||
| 125 | @SuppressWarnings("BooleanMethodIsAlwaysInverted") | |
| 126 | public boolean isSquashable(EvaluationEntry nextEntry) { | |
| 127 |
2
1. isSquashable : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry::isSquashable → NO_COVERAGE 2. isSquashable : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry::isSquashable → NO_COVERAGE |
return this.squashable; |
| 128 | } | |
| 129 | ||
| 130 | public abstract boolean requiresExplanation(); | |
| 131 | ||
| 132 | public int level() { | |
| 133 |
1
1. level : replaced int return with 0 for com/github/valid8j/pcond/core/EvaluationEntry::level → KILLED |
return level; |
| 134 | } | |
| 135 | ||
| 136 | public Object inputExpectation() { | |
| 137 |
1
1. inputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::inputExpectation → KILLED |
return this.inputExpectation; |
| 138 | } | |
| 139 | ||
| 140 | public Object detailInputExpectation() { | |
| 141 |
1
1. detailInputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::detailInputExpectation → SURVIVED |
return this.detailInputExpectation; |
| 142 | } | |
| 143 | ||
| 144 | public Object outputExpectation() { | |
| 145 |
1
1. outputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::outputExpectation → KILLED |
return this.outputExpectation; |
| 146 | } | |
| 147 | ||
| 148 | public Object detailOutputExpectation() { | |
| 149 |
1
1. detailOutputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::detailOutputExpectation → KILLED |
return this.detailOutputExpectation; |
| 150 | } | |
| 151 | ||
| 152 | public Object inputActualValue() { | |
| 153 |
1
1. inputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::inputActualValue → KILLED |
return this.inputActualValue; |
| 154 | } | |
| 155 | ||
| 156 | public abstract Object outputActualValue(); | |
| 157 | ||
| 158 | public abstract Object detailOutputActualValue(); | |
| 159 | ||
| 160 | public abstract boolean ignored(); | |
| 161 | ||
| 162 | @Override | |
| 163 | public String toString() { | |
| 164 |
1
1. toString : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry::toString → NO_COVERAGE |
return String.format("%s(%s)", formName(), inputActualValue()); |
| 165 | } | |
| 166 | ||
| 167 | static String composeDetailOutputActualValueFromInputAndThrowable(Object input, Throwable throwable) { | |
| 168 | StringBuilder b = new StringBuilder(); | |
| 169 | b.append("Input: '").append(input).append("'").append(format("%n")); | |
| 170 |
1
1. composeDetailOutputActualValueFromInputAndThrowable : negated conditional → KILLED |
b.append("Input Type: ").append(input == null ? "(null)" : input.getClass().getName()).append(format("%n")); |
| 171 | b.append("Thrown Exception: '").append(throwable.getClass().getName()).append("'").append(format("%n")); | |
| 172 | b.append("Exception Message: ").append(sanitizeExceptionMessage(throwable)).append(format("%n")); | |
| 173 | ||
| 174 | for (StackTraceElement each : foldInternalPackageElements(throwable)) { | |
| 175 | b.append("\t"); | |
| 176 | b.append(each); | |
| 177 | b.append(format("%n")); | |
| 178 | } | |
| 179 |
1
1. composeDetailOutputActualValueFromInputAndThrowable : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry::composeDetailOutputActualValueFromInputAndThrowable → KILLED |
return b.toString(); |
| 180 | } | |
| 181 | ||
| 182 | private static String sanitizeExceptionMessage(Throwable throwable) { | |
| 183 |
1
1. sanitizeExceptionMessage : negated conditional → KILLED |
if (throwable.getMessage() == null) |
| 184 |
1
1. sanitizeExceptionMessage : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry::sanitizeExceptionMessage → SURVIVED |
return null; |
| 185 |
1
1. sanitizeExceptionMessage : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry::sanitizeExceptionMessage → KILLED |
return Arrays.stream(throwable.getMessage().split("\n")) |
| 186 |
1
1. lambda$sanitizeExceptionMessage$0 : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry::lambda$sanitizeExceptionMessage$0 → KILLED |
.map(s -> "> " + s) |
| 187 | .collect(joining(String.format("%n"))); | |
| 188 | } | |
| 189 | ||
| 190 | static <T, E extends Evaluable<T>> Object computeInputActualValue(EvaluableIo<T, E, ?> evaluableIo) { | |
| 191 |
1
1. computeInputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeInputActualValue → KILLED |
return evaluableIo.input().value(); |
| 192 | } | |
| 193 | ||
| 194 | static <T, E extends Evaluable<T>> Object computeOutputExpectation(EvaluableIo<T, E, ?> evaluableIo, boolean expectationFlipped) { | |
| 195 | final State state = evaluableIo.output().state(); | |
| 196 |
1
1. computeOutputExpectation : negated conditional → KILLED |
if (state == VALUE_RETURNED) { |
| 197 |
2
1. computeOutputExpectation : negated conditional → KILLED 2. computeOutputExpectation : negated conditional → KILLED |
if (evaluableIo.evaluableType() == FUNCTION || evaluableIo.evaluableType() == TRANSFORM) |
| 198 |
1
1. computeOutputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeOutputExpectation → KILLED |
return toSnapshotIfPossible(evaluableIo.output().returnedValue()); |
| 199 |
2
1. computeOutputExpectation : negated conditional → KILLED 2. computeOutputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeOutputExpectation → KILLED |
return !expectationFlipped; |
| 200 |
2
1. computeOutputExpectation : negated conditional → KILLED 2. computeOutputExpectation : negated conditional → KILLED |
} else if (state == State.EXCEPTION_THROWN || state == State.EVALUATION_SKIPPED) |
| 201 |
1
1. computeOutputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeOutputExpectation → SURVIVED |
return EVALUATION_SKIPPED; |
| 202 | else | |
| 203 | throw new AssertionError("output state=<" + state + ">"); | |
| 204 | } | |
| 205 | ||
| 206 | static <T, E extends Evaluable<T>> Object computeOutputActualValue(EvaluableIo<T, E, ?> evaluableIo) { | |
| 207 |
1
1. computeOutputActualValue : negated conditional → KILLED |
if (evaluableIo.output().state() == State.VALUE_RETURNED) |
| 208 |
1
1. computeOutputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeOutputActualValue → KILLED |
return toSnapshotIfPossible(evaluableIo.output().returnedValue()); |
| 209 |
1
1. computeOutputActualValue : negated conditional → KILLED |
if (evaluableIo.output().state() == State.EXCEPTION_THROWN) |
| 210 |
1
1. computeOutputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeOutputActualValue → SURVIVED |
return evaluableIo.output().thrownException(); |
| 211 | else | |
| 212 |
1
1. computeOutputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::computeOutputActualValue → SURVIVED |
return EVALUATION_SKIPPED; |
| 213 | } | |
| 214 | ||
| 215 | static <T, E extends Evaluable<T>> boolean isExplanationRequired(EvaluableIo<T, E, ?> evaluableIo, boolean expectationFlipped) { | |
| 216 |
2
1. isExplanationRequired : negated conditional → KILLED 2. isExplanationRequired : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry::isExplanationRequired → KILLED |
return asList(FUNCTION, LEAF).contains(evaluableIo.evaluableType()) && ( |
| 217 |
1
1. isExplanationRequired : negated conditional → KILLED |
evaluableIo.output().state() == State.EXCEPTION_THROWN || ( |
| 218 |
2
1. isExplanationRequired : negated conditional → KILLED 2. isExplanationRequired : negated conditional → KILLED |
evaluableIo.evaluable() instanceof Evaluable.LeafPred && returnedValueOrVoidIfSkipped(expectationFlipped, evaluableIo))); |
| 219 | } | |
| 220 | ||
| 221 | private static List<StackTraceElement> foldInternalPackageElements(Throwable throwable) { | |
| 222 | AtomicReference<StackTraceElement> firstInternalStackElement = new AtomicReference<>(); | |
| 223 | String lastPackageNameElementPattern = "\\.[a-zA-Z0-9_.]+$"; | |
| 224 | String internalPackageName = Validator.class.getPackage().getName() | |
| 225 | .replaceFirst(lastPackageNameElementPattern, "") | |
| 226 | .replaceFirst(lastPackageNameElementPattern, ""); | |
| 227 |
1
1. foldInternalPackageElements : replaced return value with Collections.emptyList for com/github/valid8j/pcond/core/EvaluationEntry::foldInternalPackageElements → SURVIVED |
return Arrays.stream(throwable.getStackTrace()) |
| 228 | .filter(e -> { | |
| 229 |
1
1. lambda$foldInternalPackageElements$1 : negated conditional → SURVIVED |
if (e.getClassName().startsWith(internalPackageName)) { |
| 230 |
1
1. lambda$foldInternalPackageElements$1 : negated conditional → SURVIVED |
if (firstInternalStackElement.get() == null) { |
| 231 |
1
1. lambda$foldInternalPackageElements$1 : removed call to java/util/concurrent/atomic/AtomicReference::set → SURVIVED |
firstInternalStackElement.set(e); |
| 232 |
1
1. lambda$foldInternalPackageElements$1 : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry::lambda$foldInternalPackageElements$1 → SURVIVED |
return true; |
| 233 | } | |
| 234 |
1
1. lambda$foldInternalPackageElements$1 : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry::lambda$foldInternalPackageElements$1 → SURVIVED |
return false; |
| 235 | } | |
| 236 |
1
1. lambda$foldInternalPackageElements$1 : removed call to java/util/concurrent/atomic/AtomicReference::set → SURVIVED |
firstInternalStackElement.set(null); |
| 237 |
1
1. lambda$foldInternalPackageElements$1 : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry::lambda$foldInternalPackageElements$1 → SURVIVED |
return true; |
| 238 | }) | |
| 239 | .map(e -> { | |
| 240 |
1
1. lambda$foldInternalPackageElements$2 : negated conditional → SURVIVED |
if (e.getClassName().startsWith(internalPackageName)) { |
| 241 |
1
1. lambda$foldInternalPackageElements$2 : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::lambda$foldInternalPackageElements$2 → SURVIVED |
return new StackTraceElement("...internal.package.InternalClass", "internalMethod", "InternalClass.java", 0); |
| 242 | } | |
| 243 |
1
1. lambda$foldInternalPackageElements$2 : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::lambda$foldInternalPackageElements$2 → SURVIVED |
return e; |
| 244 | }) | |
| 245 | .collect(toList()); | |
| 246 | } | |
| 247 | ||
| 248 | private static boolean returnedValueOrVoidIfSkipped(boolean expectationFlipped, EvaluableIo<?, ?, ?> io) { | |
| 249 |
1
1. returnedValueOrVoidIfSkipped : negated conditional → KILLED |
if (io.output().state() == State.EVALUATION_SKIPPED) |
| 250 |
1
1. returnedValueOrVoidIfSkipped : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry::returnedValueOrVoidIfSkipped → KILLED |
return false; |
| 251 |
4
1. returnedValueOrVoidIfSkipped : Replaced XOR with AND → KILLED 2. returnedValueOrVoidIfSkipped : negated conditional → KILLED 3. returnedValueOrVoidIfSkipped : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry::returnedValueOrVoidIfSkipped → KILLED 4. returnedValueOrVoidIfSkipped : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry::returnedValueOrVoidIfSkipped → KILLED |
return expectationFlipped ^ !(Boolean) io.output().returnedValue(); |
| 252 | } | |
| 253 | ||
| 254 | public boolean isTrivial() { | |
| 255 |
2
1. isTrivial : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry::isTrivial → SURVIVED 2. isTrivial : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry::isTrivial → KILLED |
return this.trivial; |
| 256 | } | |
| 257 | ||
| 258 | public enum Type { | |
| 259 | TRANSFORM_AND_CHECK { | |
| 260 | @Override | |
| 261 | String formName(Evaluable<?> evaluable) { | |
| 262 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$1::formName → KILLED |
return "transformAndCheck"; |
| 263 | } | |
| 264 | }, | |
| 265 | TRANSFORM { | |
| 266 | @Override | |
| 267 | String formName(Evaluable<?> evaluable) { | |
| 268 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$2::formName → SURVIVED |
return "transform"; |
| 269 | } | |
| 270 | ||
| 271 | @Override | |
| 272 | boolean isSquashableWith(Impl nextEntry) { | |
| 273 |
1
1. isSquashableWith : negated conditional → KILLED |
if (Objects.equals(FUNCTION, nextEntry.evaluableIo().evaluableType())) |
| 274 |
2
1. isSquashableWith : negated conditional → KILLED 2. isSquashableWith : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Type$2::isSquashableWith → KILLED |
return !((Evaluable.Func<?>) nextEntry.evaluableIo().evaluable()).tail().isPresent(); |
| 275 |
1
1. isSquashableWith : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Type$2::isSquashableWith → NO_COVERAGE |
return false; |
| 276 | } | |
| 277 | }, | |
| 278 | CHECK { | |
| 279 | @Override | |
| 280 | String formName(Evaluable<?> evaluable) { | |
| 281 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$3::formName → KILLED |
return resolveEvaluationEntryType(evaluable).formName(evaluable); |
| 282 | } | |
| 283 | ||
| 284 | @Override | |
| 285 | boolean isSquashableWith(Impl nextEntry) { | |
| 286 |
2
1. isSquashableWith : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Type$3::isSquashableWith → SURVIVED 2. isSquashableWith : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Type$3::isSquashableWith → KILLED |
return asList(LEAF, NOT, AND, OR, TRANSFORM).contains(nextEntry.evaluableIo().evaluableType()); |
| 287 | } | |
| 288 | }, | |
| 289 | AND { | |
| 290 | @Override | |
| 291 | String formName(Evaluable<?> evaluable) { | |
| 292 |
2
1. formName : negated conditional → KILLED 2. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$4::formName → KILLED |
return ((Evaluable.Conjunction<?>) evaluable).shortcut() ? "and" : "allOf"; |
| 293 | } | |
| 294 | }, | |
| 295 | OR { | |
| 296 | @Override | |
| 297 | String formName(Evaluable<?> evaluable) { | |
| 298 |
2
1. formName : negated conditional → KILLED 2. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$5::formName → KILLED |
return ((Evaluable.Disjunction<?>) evaluable).shortcut() ? "or" : "anyOf"; |
| 299 | } | |
| 300 | }, | |
| 301 | NOT { | |
| 302 | @Override | |
| 303 | String formName(Evaluable<?> evaluable) { | |
| 304 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$6::formName → KILLED |
return "not"; |
| 305 | } | |
| 306 | ||
| 307 | @Override | |
| 308 | boolean isSquashableWith(Impl nextEntry) { | |
| 309 |
2
1. isSquashableWith : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Type$6::isSquashableWith → SURVIVED 2. isSquashableWith : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Type$6::isSquashableWith → KILLED |
return Objects.equals(LEAF, nextEntry.evaluableIo().evaluableType()); |
| 310 | } | |
| 311 | }, | |
| 312 | LEAF { | |
| 313 | @Override | |
| 314 | String formName(Evaluable<?> evaluable) { | |
| 315 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$7::formName → KILLED |
return evaluable.toString(); |
| 316 | } | |
| 317 | }, | |
| 318 | FUNCTION { | |
| 319 | @Override | |
| 320 | String formName(Evaluable<?> evaluable) { | |
| 321 |
1
1. formName : negated conditional → KILLED |
if (DebuggingUtils.showEvaluableDetail()) { |
| 322 |
1
1. formName : negated conditional → NO_COVERAGE |
if (!((Evaluable.Func<?>) evaluable).tail().isPresent()) |
| 323 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$8::formName → NO_COVERAGE |
return ((Evaluable.Func<?>) evaluable).head().toString(); |
| 324 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$8::formName → NO_COVERAGE |
return ((Evaluable.Func<?>) evaluable).head().toString() + "(" + ((Evaluable.Func<?>) evaluable).tail().get() + ")"; |
| 325 | } | |
| 326 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Type$8::formName → KILLED |
return ((Evaluable.Func<?>) evaluable).head().toString(); |
| 327 | } | |
| 328 | }; | |
| 329 | ||
| 330 | abstract String formName(Evaluable<?> evaluable); | |
| 331 | ||
| 332 | boolean isSquashableWith(Impl nextEntry) { | |
| 333 |
1
1. isSquashableWith : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Type::isSquashableWith → KILLED |
return false; |
| 334 | } | |
| 335 | } | |
| 336 | ||
| 337 | static class Finalized extends EvaluationEntry { | |
| 338 | final Object outputActualValue; | |
| 339 | final Object detailOutputActualValue; | |
| 340 | private final boolean requiresExplanation; | |
| 341 | private final boolean ignored; | |
| 342 | ||
| 343 | Finalized( | |
| 344 | String formName, | |
| 345 | Type type, | |
| 346 | int level, | |
| 347 | Object inputExpectation_, Object detailInputExpectation_, | |
| 348 | Object outputExpectation, Object detailOutputExpectation, | |
| 349 | Object inputActualValue, Object detailInputActualValue, | |
| 350 | Object outputActualValue, Object detailOutputActualValue, | |
| 351 | boolean squashable, boolean trivial, boolean requiresExplanation, boolean ignored) { | |
| 352 | super( | |
| 353 | formName, type, level, | |
| 354 | inputExpectation_, detailInputExpectation_, | |
| 355 | outputExpectation, detailOutputExpectation, | |
| 356 | inputActualValue, detailInputActualValue, | |
| 357 | squashable, trivial); | |
| 358 | this.outputActualValue = outputActualValue; | |
| 359 | this.detailOutputActualValue = detailOutputActualValue; | |
| 360 | this.requiresExplanation = requiresExplanation; | |
| 361 | this.ignored = ignored; | |
| 362 | } | |
| 363 | ||
| 364 | @Override | |
| 365 | public Object outputActualValue() { | |
| 366 |
1
1. outputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Finalized::outputActualValue → KILLED |
return outputActualValue; |
| 367 | } | |
| 368 | ||
| 369 | @Override | |
| 370 | public Object detailOutputActualValue() { | |
| 371 |
1
1. detailOutputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Finalized::detailOutputActualValue → KILLED |
return this.detailOutputActualValue; |
| 372 | } | |
| 373 | ||
| 374 | @Override | |
| 375 | public boolean ignored() { | |
| 376 |
2
1. ignored : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Finalized::ignored → NO_COVERAGE 2. ignored : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Finalized::ignored → NO_COVERAGE |
return this.ignored; |
| 377 | } | |
| 378 | ||
| 379 | @Override | |
| 380 | public boolean requiresExplanation() { | |
| 381 |
2
1. requiresExplanation : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Finalized::requiresExplanation → KILLED 2. requiresExplanation : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Finalized::requiresExplanation → KILLED |
return this.requiresExplanation; |
| 382 | } | |
| 383 | } | |
| 384 | ||
| 385 | public static EvaluationEntry create( | |
| 386 | String formName, Type type, | |
| 387 | int level, | |
| 388 | Object inputExpectation_, Object detailInputExpectation_, | |
| 389 | Object outputExpectation, Object detailOutputExpectation, | |
| 390 | Object inputActualValue, Object detailInputActualValue, | |
| 391 | Object outputActualValue, Object detailOutputActualValue, | |
| 392 | boolean squashable, boolean trivial, boolean requiresExplanation, boolean ignored) { | |
| 393 |
1
1. create : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry::create → KILLED |
return new Finalized( |
| 394 | formName, type, | |
| 395 | level, | |
| 396 | inputExpectation_, detailInputExpectation_, | |
| 397 | outputExpectation, detailOutputExpectation, | |
| 398 | inputActualValue, detailInputActualValue, | |
| 399 | outputActualValue, detailOutputActualValue, | |
| 400 | squashable, trivial, requiresExplanation, ignored | |
| 401 | ); | |
| 402 | } | |
| 403 | ||
| 404 | public static class Impl extends EvaluationEntry { | |
| 405 | ||
| 406 | private final EvaluableIo<?, ?, ?> evaluableIo; | |
| 407 | private final boolean expectationFlipped; | |
| 408 | private boolean ignored; | |
| 409 | ||
| 410 | private boolean finalized = false; | |
| 411 | private Object outputActualValue; | |
| 412 | private Object detailOutputActualValue; | |
| 413 | ||
| 414 | <T, E extends Evaluable<T>> Impl( | |
| 415 | EvaluationContext<T> evaluationContext, | |
| 416 | EvaluableIo<T, E, ?> evaluableIo) { | |
| 417 | super( | |
| 418 | EvaluationContext.formNameOf(evaluableIo), | |
| 419 | evaluableIo.evaluableType(), | |
| 420 | evaluationContext.visitorLineage.size(), | |
| 421 | computeInputExpectation(evaluableIo), // inputExpectation == inputActualValue | |
| 422 | explainInputExpectation(evaluableIo), // detailInputExpectation == detailInputActualValue | |
| 423 | null, // not necessary // outputExpectation | |
| 424 | explainOutputExpectation(evaluableIo.evaluable(), evaluableIo), // detailOutputExpectation | |
| 425 | computeInputActualValue(evaluableIo), // inputActualValue | |
| 426 | explainInputActualValue(evaluableIo.evaluable(), computeInputActualValue(evaluableIo)), // detailInputActualValue | |
| 427 | evaluableIo.evaluable().isSquashable(), | |
| 428 | evaluableIo.evaluable().isTrivial()); | |
| 429 | this.evaluableIo = evaluableIo; | |
| 430 | this.expectationFlipped = evaluationContext.isExpectationFlipped(); | |
| 431 | this.ignored = false; | |
| 432 | } | |
| 433 | ||
| 434 | private static <E extends Evaluable<T>, T> Object explainInputExpectation(EvaluableIo<T, E, ?> evaluableIo) { | |
| 435 |
1
1. explainInputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Impl::explainInputExpectation → SURVIVED |
return explainInputActualValue(evaluableIo, computeInputExpectation(evaluableIo)); |
| 436 | } | |
| 437 | ||
| 438 | private static <E extends Evaluable<T>, T> Object computeInputExpectation(EvaluableIo<T, E, ?> evaluableIo) { | |
| 439 |
1
1. computeInputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Impl::computeInputExpectation → KILLED |
return computeInputActualValue(evaluableIo); |
| 440 | } | |
| 441 | ||
| 442 | @Override | |
| 443 | public boolean requiresExplanation() { | |
| 444 |
2
1. requiresExplanation : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Impl::requiresExplanation → KILLED 2. requiresExplanation : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Impl::requiresExplanation → KILLED |
return isExplanationRequired(evaluableIo(), this.expectationFlipped); |
| 445 | } | |
| 446 | ||
| 447 | @SuppressWarnings("unchecked") | |
| 448 | public <I, O> EvaluableIo<I, Evaluable<I>, O> evaluableIo() { | |
| 449 |
1
1. evaluableIo : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Impl::evaluableIo → KILLED |
return (EvaluableIo<I, Evaluable<I>, O>) this.evaluableIo; |
| 450 | } | |
| 451 | ||
| 452 | public Object outputExpectation() { | |
| 453 | assert finalized; | |
| 454 |
1
1. outputExpectation : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Impl::outputExpectation → KILLED |
return outputExpectation; |
| 455 | } | |
| 456 | ||
| 457 | @Override | |
| 458 | public Object outputActualValue() { | |
| 459 | assert finalized; | |
| 460 |
1
1. outputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Impl::outputActualValue → KILLED |
return outputActualValue; |
| 461 | } | |
| 462 | ||
| 463 | @Override | |
| 464 | public Object detailOutputActualValue() { | |
| 465 | assert finalized; | |
| 466 |
1
1. detailOutputActualValue : replaced return value with null for com/github/valid8j/pcond/core/EvaluationEntry$Impl::detailOutputActualValue → KILLED |
return detailOutputActualValue; |
| 467 | } | |
| 468 | ||
| 469 | public boolean ignored() { | |
| 470 | assert finalized; | |
| 471 |
2
1. ignored : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Impl::ignored → KILLED 2. ignored : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Impl::ignored → KILLED |
return this.ignored; |
| 472 | } | |
| 473 | ||
| 474 | public boolean isSquashable(EvaluationEntry nextEntry) { | |
| 475 |
1
1. isSquashable : negated conditional → KILLED |
if (nextEntry instanceof Impl) |
| 476 |
2
1. isSquashable : replaced boolean return with false for com/github/valid8j/pcond/core/EvaluationEntry$Impl::isSquashable → KILLED 2. isSquashable : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Impl::isSquashable → KILLED |
return this.type().isSquashableWith((Impl) nextEntry); |
| 477 |
1
1. isSquashable : replaced boolean return with true for com/github/valid8j/pcond/core/EvaluationEntry$Impl::isSquashable → NO_COVERAGE |
return false; |
| 478 | } | |
| 479 | ||
| 480 | public String formName() { | |
| 481 |
1
1. formName : negated conditional → KILLED |
if (DebuggingUtils.showEvaluableDetail()) |
| 482 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Impl::formName → NO_COVERAGE |
return evaluableIo.formName() + "(" + |
| 483 | evaluableIo.evaluableType() + ":" + | |
| 484 | evaluableIo.input().creatorFormType() + ":" + | |
| 485 |
1
1. formName : negated conditional → NO_COVERAGE |
evaluableIo.output().creatorFormType() + |
| 486 |
1
1. formName : negated conditional → NO_COVERAGE |
(finalized && this.ignored() ? ":ignored" : "") + ")"; |
| 487 |
1
1. formName : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Impl::formName → KILLED |
return this.evaluableIo.formName(); |
| 488 | } | |
| 489 | ||
| 490 | public void finalizeValues() { | |
| 491 | this.outputExpectation = computeOutputExpectation(evaluableIo(), expectationFlipped); | |
| 492 | this.outputActualValue = computeOutputActualValue(evaluableIo()); | |
| 493 | this.detailOutputActualValue = explainActual(evaluableIo()); | |
| 494 | this.ignored = | |
| 495 |
2
1. finalizeValues : negated conditional → KILLED 2. finalizeValues : negated conditional → KILLED |
(this.evaluableIo.evaluableType() == TRANSFORM_AND_CHECK && this.evaluableIo.formName().equals("transformAndCheck")) || |
| 496 |
2
1. finalizeValues : negated conditional → KILLED 2. finalizeValues : negated conditional → KILLED |
(this.evaluableIo.evaluableType() == FUNCTION && this.evaluableIo.output().creatorFormType() == FUNC_TAIL); |
| 497 | this.finalized = true; | |
| 498 | } | |
| 499 | ||
| 500 | @Override | |
| 501 | public String toString() { | |
| 502 |
3
1. toString : negated conditional → NO_COVERAGE 2. toString : negated conditional → NO_COVERAGE 3. toString : replaced return value with "" for com/github/valid8j/pcond/core/EvaluationEntry$Impl::toString → NO_COVERAGE |
return String.format("%s(%s)=%s (expected:=%s):%s", formName(), inputActualValue(), finalized ? outputActualValue() : "(n/a)", finalized ? outputExpectation() : "(n/a)", this.level()); |
| 503 | } | |
| 504 | } | |
| 505 | } | |
Mutations | ||
| 118 |
1.1 |
|
| 122 |
1.1 |
|
| 127 |
1.1 2.2 |
|
| 133 |
1.1 |
|
| 137 |
1.1 |
|
| 141 |
1.1 |
|
| 145 |
1.1 |
|
| 149 |
1.1 |
|
| 153 |
1.1 |
|
| 164 |
1.1 |
|
| 170 |
1.1 |
|
| 179 |
1.1 |
|
| 183 |
1.1 |
|
| 184 |
1.1 |
|
| 185 |
1.1 |
|
| 186 |
1.1 |
|
| 191 |
1.1 |
|
| 196 |
1.1 |
|
| 197 |
1.1 2.2 |
|
| 198 |
1.1 |
|
| 199 |
1.1 2.2 |
|
| 200 |
1.1 2.2 |
|
| 201 |
1.1 |
|
| 207 |
1.1 |
|
| 208 |
1.1 |
|
| 209 |
1.1 |
|
| 210 |
1.1 |
|
| 212 |
1.1 |
|
| 216 |
1.1 2.2 |
|
| 217 |
1.1 |
|
| 218 |
1.1 2.2 |
|
| 227 |
1.1 |
|
| 229 |
1.1 |
|
| 230 |
1.1 |
|
| 231 |
1.1 |
|
| 232 |
1.1 |
|
| 234 |
1.1 |
|
| 236 |
1.1 |
|
| 237 |
1.1 |
|
| 240 |
1.1 |
|
| 241 |
1.1 |
|
| 243 |
1.1 |
|
| 249 |
1.1 |
|
| 250 |
1.1 |
|
| 251 |
1.1 2.2 3.3 4.4 |
|
| 255 |
1.1 2.2 |
|
| 262 |
1.1 |
|
| 268 |
1.1 |
|
| 273 |
1.1 |
|
| 274 |
1.1 2.2 |
|
| 275 |
1.1 |
|
| 281 |
1.1 |
|
| 286 |
1.1 2.2 |
|
| 292 |
1.1 2.2 |
|
| 298 |
1.1 2.2 |
|
| 304 |
1.1 |
|
| 309 |
1.1 2.2 |
|
| 315 |
1.1 |
|
| 321 |
1.1 |
|
| 322 |
1.1 |
|
| 323 |
1.1 |
|
| 324 |
1.1 |
|
| 326 |
1.1 |
|
| 333 |
1.1 |
|
| 366 |
1.1 |
|
| 371 |
1.1 |
|
| 376 |
1.1 2.2 |
|
| 381 |
1.1 2.2 |
|
| 393 |
1.1 |
|
| 435 |
1.1 |
|
| 439 |
1.1 |
|
| 444 |
1.1 2.2 |
|
| 449 |
1.1 |
|
| 454 |
1.1 |
|
| 460 |
1.1 |
|
| 466 |
1.1 |
|
| 471 |
1.1 2.2 |
|
| 475 |
1.1 |
|
| 476 |
1.1 2.2 |
|
| 477 |
1.1 |
|
| 481 |
1.1 |
|
| 482 |
1.1 |
|
| 485 |
1.1 |
|
| 486 |
1.1 |
|
| 487 |
1.1 |
|
| 495 |
1.1 2.2 |
|
| 496 |
1.1 2.2 |
|
| 502 |
1.1 2.2 3.3 |