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