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