| 1 | package com.github.dakusui.pcond.internals; | |
| 2 | ||
| 3 | import com.github.dakusui.pcond.core.Evaluable; | |
| 4 | import com.github.dakusui.pcond.core.printable.PrintableFunction; | |
| 5 | import com.github.dakusui.pcond.core.printable.PrintablePredicate; | |
| 6 | import com.github.dakusui.pcond.forms.Functions; | |
| 7 | import com.github.dakusui.pcond.forms.Printables; | |
| 8 | import com.github.dakusui.pcond.validator.Explanation; | |
| 9 | import com.github.dakusui.pcond.validator.Validator; | |
| 10 | ||
| 11 | import java.lang.reflect.InvocationTargetException; | |
| 12 | import java.lang.reflect.Method; | |
| 13 | import java.util.*; | |
| 14 | import java.util.function.Function; | |
| 15 | import java.util.function.Predicate; | |
| 16 | ||
| 17 | import static java.lang.String.format; | |
| 18 | import static java.util.Arrays.asList; | |
| 19 | import static java.util.Collections.unmodifiableList; | |
| 20 | import static java.util.Objects.requireNonNull; | |
| 21 | import static java.util.stream.Collectors.joining; | |
| 22 | ||
| 23 | public enum InternalUtils { | |
| 24 | ; | |
| 25 | ||
| 26 | private static final Predicate<?> DUMMY_PREDICATE = Printables.predicate("DUMMY_PREDICATE:ALWAYSTHROW", v -> { | |
| 27 | throw new UnsupportedOperationException("Testing: '" + v + "' was failed, because this is a dummy predicate."); | |
| 28 | }); | |
| 29 | private static final Function<?, ?> DUMMY_FUNCTION = Printables.function("DUMMY_FUNCTION:ALWAYSTHROW", v -> { | |
| 30 | throw new UnsupportedOperationException("Applying: '" + v + "' was failed, because this is a dummy predicate."); | |
| 31 | }); | |
| 32 | ||
| 33 | public static String formatObject(Object value) { | |
| 34 |
1
1. formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::formatObject → KILLED |
return formatObject(value, summarizedStringLength()); |
| 35 | } | |
| 36 | ||
| 37 | public static String formatObject(Object value, int maxLength) { | |
| 38 |
1
1. formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::formatObject → KILLED |
return _formatObject(value, maxLength).replaceAll("[\\r\\n]", " "); |
| 39 | } | |
| 40 | ||
| 41 | private static String _formatObject(Object value, int maxLength) { | |
| 42 |
1
1. _formatObject : negated conditional → KILLED |
if (value == null) |
| 43 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return "null"; |
| 44 |
1
1. _formatObject : negated conditional → KILLED |
if (value instanceof Collection) { |
| 45 | Collection<?> collection = (Collection<?>) value; | |
| 46 |
2
1. _formatObject : changed conditional boundary → KILLED 2. _formatObject : negated conditional → KILLED |
if (collection.size() < 4) |
| 47 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return format("[%s]", |
| 48 | collection.stream() | |
| 49 | .map(InternalUtils::formatObject) | |
| 50 | .collect(joining(","))); | |
| 51 | Iterator<?> i = collection.iterator(); | |
| 52 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return format("[%s,%s,%s...;%s]", |
| 53 | formatObject(i.next()), | |
| 54 | formatObject(i.next()), | |
| 55 | formatObject(i.next()), | |
| 56 | collection.size() | |
| 57 | ); | |
| 58 | } | |
| 59 |
1
1. _formatObject : negated conditional → KILLED |
if (value instanceof Object[]) |
| 60 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return formatObject(asList((Object[]) value)); |
| 61 |
1
1. _formatObject : negated conditional → KILLED |
if (value instanceof Formattable) |
| 62 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return String.format("%s", value); |
| 63 |
1
1. _formatObject : negated conditional → KILLED |
if (value instanceof String) { |
| 64 | String s = (String) value; | |
| 65 | s = summarizeString(s, maxLength); | |
| 66 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return format("\"%s\"", s); |
| 67 | } | |
| 68 |
1
1. _formatObject : negated conditional → KILLED |
if (value instanceof Throwable) { |
| 69 | Throwable throwable = (Throwable) value; | |
| 70 | String simpleName = summarizeString(throwable.getClass().getSimpleName() + ":", maxLength); | |
| 71 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return simpleName + |
| 72 |
2
1. _formatObject : changed conditional boundary → SURVIVED 2. _formatObject : negated conditional → KILLED |
(simpleName.length() < Math.max(12, maxLength) ? |
| 73 |
1
1. _formatObject : Replaced integer subtraction with addition → KILLED |
formatObject(throwable.getMessage(), toNextEven(Math.max(12, maxLength - simpleName.length()))) : |
| 74 | ""); | |
| 75 | } | |
| 76 |
1
1. _formatObject : negated conditional → KILLED |
if (isToStringOverridden(value)) |
| 77 |
1
1. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return summarizeString( |
| 78 |
1
1. _formatObject : Replaced integer addition with subtraction → KILLED |
value.toString(), |
| 79 | maxLength + 2 /* 2 for margin for single quotes not necessary for non-strings */ | |
| 80 | ); | |
| 81 |
2
1. _formatObject : Replaced integer addition with subtraction → KILLED 2. _formatObject : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::_formatObject → KILLED |
return value.toString().substring(value.getClass().getPackage().getName().length() + 1); |
| 82 | } | |
| 83 | ||
| 84 | public static String explainValue(Object value) { | |
| 85 | StringBuilder b = new StringBuilder(); | |
| 86 |
1
1. explainValue : negated conditional → KILLED |
if (value instanceof Collection) { |
| 87 | for (Object each : (Collection<?>) value) { | |
| 88 |
1
1. explainValue : removed call to com/github/dakusui/pcond/internals/InternalUtils::explainValue → SURVIVED |
explainValue(b, 0, each); |
| 89 | } | |
| 90 | } else { | |
| 91 |
1
1. explainValue : removed call to com/github/dakusui/pcond/internals/InternalUtils::explainValue → KILLED |
explainValue(b, 0, value); |
| 92 | } | |
| 93 |
1
1. explainValue : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::explainValue → KILLED |
return b.toString().trim(); |
| 94 | } | |
| 95 | ||
| 96 | private static void explainValue(StringBuilder buffer, int level, Object value) { | |
| 97 |
1
1. explainValue : negated conditional → KILLED |
if (value instanceof Collection) { |
| 98 |
1
1. explainValue : negated conditional → NO_COVERAGE |
if (((Collection<?>) value).isEmpty()) |
| 99 |
1
1. explainValue : removed call to com/github/dakusui/pcond/internals/InternalUtils::explainValue → NO_COVERAGE |
explainValue(buffer, level, "[]"); |
| 100 | else { | |
| 101 | for (Object each : (Collection<?>) value) | |
| 102 |
2
1. explainValue : Replaced integer addition with subtraction → NO_COVERAGE 2. explainValue : removed call to com/github/dakusui/pcond/internals/InternalUtils::explainValue → NO_COVERAGE |
explainValue(buffer, level + 1, each); |
| 103 | } | |
| 104 | } else { | |
| 105 |
1
1. explainValue : Replaced integer multiplication with division → SURVIVED |
buffer.append(String.format("%s%s%n", spaces(level * 2), value)); |
| 106 | } | |
| 107 | } | |
| 108 | ||
| 109 | private static String spaces(int spaces) { | |
| 110 |
2
1. spaces : changed conditional boundary → KILLED 2. spaces : negated conditional → KILLED |
if (spaces <= 0) |
| 111 | return ""; | |
| 112 |
1
1. spaces : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::spaces → NO_COVERAGE |
return String.format("%-" + (spaces) + "s", ""); |
| 113 | } | |
| 114 | ||
| 115 | private static int toNextEven(int value) { | |
| 116 |
2
1. toNextEven : Replaced bitwise AND with OR → KILLED 2. toNextEven : negated conditional → KILLED |
if ((value & 1) == 0) |
| 117 |
1
1. toNextEven : replaced int return with 0 for com/github/dakusui/pcond/internals/InternalUtils::toNextEven → KILLED |
return value; |
| 118 |
2
1. toNextEven : Replaced integer addition with subtraction → SURVIVED 2. toNextEven : replaced int return with 0 for com/github/dakusui/pcond/internals/InternalUtils::toNextEven → KILLED |
return value + 1; |
| 119 | } | |
| 120 | ||
| 121 | private static String summarizeString(String s, int length) { | |
| 122 | assert (length & 1) == 0 : "The length must be an even int, but was <" + length + ">"; | |
| 123 | assert length >= 12 : "The length must be greater than or equal to 12. Less than 20 is not recommended. But was <" + length + ">"; | |
| 124 |
2
1. summarizeString : changed conditional boundary → KILLED 2. summarizeString : negated conditional → KILLED |
if (s.length() > length) { |
| 125 |
2
1. summarizeString : Replaced integer division with multiplication → KILLED 2. summarizeString : Replaced integer subtraction with addition → KILLED |
int pre = length / 2 - 2; |
| 126 |
2
1. summarizeString : Replaced integer division with multiplication → KILLED 2. summarizeString : Replaced integer subtraction with addition → KILLED |
int post = length / 2 - 5; |
| 127 |
2
1. summarizeString : Replaced integer subtraction with addition → KILLED 2. summarizeString : Replaced integer subtraction with addition → KILLED |
s = s.substring(0, length - pre) + "..." + s.substring(s.length() - post); |
| 128 | } | |
| 129 |
1
1. summarizeString : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::summarizeString → KILLED |
return s; |
| 130 | } | |
| 131 | ||
| 132 | public static int summarizedStringLength() { | |
| 133 |
1
1. summarizedStringLength : replaced int return with 0 for com/github/dakusui/pcond/internals/InternalUtils::summarizedStringLength → KILLED |
return Validator.instance().configuration().summarizedStringLength(); |
| 134 | } | |
| 135 | ||
| 136 | private static boolean isToStringOverridden(Object object) { | |
| 137 |
2
1. isToStringOverridden : negated conditional → KILLED 2. isToStringOverridden : replaced boolean return with true for com/github/dakusui/pcond/internals/InternalUtils::isToStringOverridden → KILLED |
return getMethod(object.getClass(), "toString").getDeclaringClass() != Object.class; |
| 138 | } | |
| 139 | ||
| 140 | /** | |
| 141 | * A method to check if assertion is enabled or not. | |
| 142 | * | |
| 143 | * @param v A boolean value to test. | |
| 144 | * @return {@code true} - assertion failed with the given value {@code v} / {@code false} - otherwise. | |
| 145 | */ | |
| 146 | public static boolean assertFailsWith(boolean v) { | |
| 147 | boolean ret = false; | |
| 148 | try { | |
| 149 | assert v; | |
| 150 | } catch (AssertionError e) { | |
| 151 | ret = true; | |
| 152 | } | |
| 153 |
2
1. assertFailsWith : replaced boolean return with false for com/github/dakusui/pcond/internals/InternalUtils::assertFailsWith → SURVIVED 2. assertFailsWith : replaced boolean return with true for com/github/dakusui/pcond/internals/InternalUtils::assertFailsWith → KILLED |
return ret; |
| 154 | } | |
| 155 | ||
| 156 | @SuppressWarnings("unchecked") | |
| 157 | public static <T> T createInstanceFromClassName(Class<? super T> expectedClass, String requestedClassName, Object... args) { | |
| 158 | try { | |
| 159 | Class<?> loadedClass = Class.forName(requestedClassName); | |
| 160 | try { | |
| 161 |
2
1. createInstanceFromClassName : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::createInstanceFromClassName → KILLED 2. lambda$createInstanceFromClassName$2 : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::lambda$createInstanceFromClassName$2 → KILLED |
return (T) expectedClass.cast(loadedClass.getDeclaredConstructor(Arrays.stream(args).map(Object::getClass).toArray(Class<?>[]::new)).newInstance(args)); |
| 162 | } catch (ClassCastException e) { | |
| 163 | throw executionFailure("The requested class:'" + requestedClassName + | |
| 164 | "' was found but not an instance of " + expectedClass.getCanonicalName() + ".: " + | |
| 165 | "It was '" + loadedClass.getCanonicalName() + "'.", | |
| 166 | e); | |
| 167 | } catch (NoSuchMethodException e) { | |
| 168 | throw executionFailure("Matching public constructor for " + Arrays.toString(args) + " was not found in " + requestedClassName, e); | |
| 169 | } catch (InvocationTargetException e) { | |
| 170 | throw executionFailure("Matching public constructor was found in " + requestedClassName + " but threw an exception", e.getCause()); | |
| 171 | } | |
| 172 | } catch (InstantiationException | IllegalAccessException | | |
| 173 | ClassNotFoundException e) { | |
| 174 | throw executionFailure("The requested class was not found or not accessible.: " + requestedClassName, e); | |
| 175 | } | |
| 176 | } | |
| 177 | ||
| 178 | public static InternalException executionFailure(String message, Throwable cause) { | |
| 179 | throw executionFailure(Explanation.fromMessage(message), cause); | |
| 180 | } | |
| 181 | ||
| 182 | public static InternalException executionFailure(Explanation explanation, Throwable cause) { | |
| 183 | throw new InternalException(explanation.toString(), cause); | |
| 184 | } | |
| 185 | ||
| 186 | public static InternalException wrapIfNecessary(Throwable cause) { | |
| 187 |
1
1. wrapIfNecessary : negated conditional → KILLED |
if (cause instanceof Error) |
| 188 | throw (Error) cause; | |
| 189 |
1
1. wrapIfNecessary : negated conditional → KILLED |
if (cause instanceof RuntimeException) |
| 190 | throw (RuntimeException) cause; | |
| 191 | throw executionFailure(cause.getMessage(), cause); | |
| 192 | } | |
| 193 | ||
| 194 | public static List<? super Object> append(List<? super Object> list, Object p) { | |
| 195 |
1
1. append : replaced return value with Collections.emptyList for com/github/dakusui/pcond/internals/InternalUtils::append → KILLED |
return unmodifiableList(new ArrayList<Object>(list) {{ |
| 196 | add(p); | |
| 197 | }}); | |
| 198 | } | |
| 199 | ||
| 200 | @SuppressWarnings("unchecked") | |
| 201 | public static <T> Evaluable<T> toEvaluableIfNecessary(Predicate<? super T> p) { | |
| 202 | requireNonNull(p); | |
| 203 |
1
1. toEvaluableIfNecessary : negated conditional → KILLED |
if (p instanceof Evaluable) |
| 204 |
1
1. toEvaluableIfNecessary : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::toEvaluableIfNecessary → KILLED |
return (Evaluable<T>) p; |
| 205 | // We know that Printable.predicate returns a PrintablePredicate object, which is an Evaluable. | |
| 206 |
1
1. toEvaluableIfNecessary : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::toEvaluableIfNecessary → KILLED |
return (Evaluable<T>) Printables.predicate(p::toString, p); |
| 207 | } | |
| 208 | ||
| 209 | public static <T> Evaluable<T> toEvaluableIfNecessary(Function<? super T, ?> f) { | |
| 210 |
1
1. toEvaluableIfNecessary : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::toEvaluableIfNecessary → KILLED |
return toEvaluableWithFormatterIfNecessary(f, Object::toString); |
| 211 | } | |
| 212 | ||
| 213 | @SuppressWarnings("unchecked") | |
| 214 | public static <T> Evaluable<T> toEvaluableWithFormatterIfNecessary(Function<? super T, ?> f, Function<Function<? super T, ?>, String> formatter) { | |
| 215 | requireNonNull(f); | |
| 216 |
1
1. toEvaluableWithFormatterIfNecessary : negated conditional → KILLED |
if (f instanceof Evaluable) |
| 217 |
1
1. toEvaluableWithFormatterIfNecessary : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::toEvaluableWithFormatterIfNecessary → KILLED |
return (Evaluable<T>) f; |
| 218 | // We know that Printable.predicate returns a PrintableFunction object, which is an Evaluable. | |
| 219 |
2
1. lambda$toEvaluableWithFormatterIfNecessary$3 : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::lambda$toEvaluableWithFormatterIfNecessary$3 → SURVIVED 2. toEvaluableWithFormatterIfNecessary : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::toEvaluableWithFormatterIfNecessary → KILLED |
return (Evaluable<T>) Printables.function(() -> formatter.apply(f), f); |
| 220 | } | |
| 221 | ||
| 222 | public static Class<?> wrapperClassOf(Class<?> clazz) { | |
| 223 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Integer.TYPE) |
| 224 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Integer.class; |
| 225 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Long.TYPE) |
| 226 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Long.class; |
| 227 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Boolean.TYPE) |
| 228 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Boolean.class; |
| 229 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Byte.TYPE) |
| 230 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Byte.class; |
| 231 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Character.TYPE) |
| 232 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Character.class; |
| 233 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Float.TYPE) |
| 234 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Float.class; |
| 235 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Double.TYPE) |
| 236 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Double.class; |
| 237 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Short.TYPE) |
| 238 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Short.class; |
| 239 |
1
1. wrapperClassOf : negated conditional → KILLED |
if (clazz == Void.TYPE) |
| 240 |
1
1. wrapperClassOf : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::wrapperClassOf → KILLED |
return Void.class; |
| 241 |
1
1. wrapperClassOf : negated conditional → KILLED |
throw new IllegalArgumentException("Unsupported type:" + (clazz != null ? clazz.getName() : "null") + " was given."); |
| 242 | } | |
| 243 | ||
| 244 | public static Method getMethod(Class<?> aClass, String methodName, Class<?>... parameterTypes) { | |
| 245 | try { | |
| 246 |
1
1. getMethod : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::getMethod → KILLED |
return aClass.getMethod(methodName, parameterTypes); |
| 247 | } catch (NoSuchMethodException e) { | |
| 248 | throw executionFailure(format("Requested method: %s(%s) was not found in %s", methodName, Arrays.stream(parameterTypes).map(Class::getName).collect(joining(",")), aClass.getName()), e); | |
| 249 | } | |
| 250 | } | |
| 251 | ||
| 252 | @SuppressWarnings("unchecked") | |
| 253 | public static <T> Predicate<? super T> dummyPredicate() { | |
| 254 |
1
1. dummyPredicate : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::dummyPredicate → KILLED |
return (Predicate<? super T>) DUMMY_PREDICATE; |
| 255 | } | |
| 256 | ||
| 257 | @SuppressWarnings("unchecked") | |
| 258 | public static <T, R> Function<T, R> dummyFunction() { | |
| 259 |
1
1. dummyFunction : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::dummyFunction → KILLED |
return (Function<T, R>) DUMMY_FUNCTION; |
| 260 | } | |
| 261 | ||
| 262 | public static boolean isDummyFunction(Function<?, ?> function) { | |
| 263 |
2
1. isDummyFunction : negated conditional → KILLED 2. isDummyFunction : replaced boolean return with true for com/github/dakusui/pcond/internals/InternalUtils::isDummyFunction → KILLED |
return function == DUMMY_FUNCTION; |
| 264 | } | |
| 265 | ||
| 266 | public static Object toNonStringObject(String s) { | |
| 267 |
1
1. toNonStringObject : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::toNonStringObject → KILLED |
return new Object() { |
| 268 | @Override | |
| 269 | public String toString() { | |
| 270 |
1
1. toString : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils$2::toString → KILLED |
return s; |
| 271 | } | |
| 272 | }; | |
| 273 | } | |
| 274 | ||
| 275 | public static String indent(int level) { | |
| 276 |
3
1. indent : Replaced integer multiplication with division → KILLED 2. indent : negated conditional → KILLED 3. indent : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::indent → KILLED |
return level == 0 ? |
| 277 | "" : | |
| 278 | format("%" + (level * 2) + "s", ""); | |
| 279 | } | |
| 280 | ||
| 281 | public static String newLine() { | |
| 282 |
1
1. newLine : replaced return value with "" for com/github/dakusui/pcond/internals/InternalUtils::newLine → KILLED |
return format("%n"); |
| 283 | } | |
| 284 | ||
| 285 | /** | |
| 286 | * Marks "trivial" a given function. | |
| 287 | * A predicate marked trivial will not appear in an execution report. | |
| 288 | * | |
| 289 | * @param predicate A predicate to be marked. | |
| 290 | * @param <T> Input type of the function. | |
| 291 | * @return A predicate marked trivial. | |
| 292 | */ | |
| 293 | public static <T> Predicate<T> makeSquashable(Predicate<T> predicate) { | |
| 294 |
1
1. makeSquashable : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::makeSquashable → KILLED |
return ((PrintablePredicate<T>) predicate).makeTrivial(); |
| 295 | } | |
| 296 | ||
| 297 | /** | |
| 298 | * Marks "trivial" given function. | |
| 299 | * A function marked trivial will not appear in an execution report. | |
| 300 | * | |
| 301 | * @param function A function to marked. | |
| 302 | * @param <T> Input type of the function. | |
| 303 | * @param <R> Output type of the function. | |
| 304 | * @return A function marked trivial. | |
| 305 | */ | |
| 306 | public static <T, R> Function<T, R> makeSquashable(Function<T, R> function) { | |
| 307 |
1
1. makeSquashable : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::makeSquashable → NO_COVERAGE |
return ((PrintableFunction<T, R>) function).makeTrivial(); |
| 308 | } | |
| 309 | ||
| 310 | public static <T> Function<T, T> trivialIdentityFunction() { | |
| 311 |
1
1. trivialIdentityFunction : replaced return value with null for com/github/dakusui/pcond/internals/InternalUtils::trivialIdentityFunction → KILLED |
return Functions.identity(); |
| 312 | } | |
| 313 | } | |
Mutations | ||
| 34 |
1.1 |
|
| 38 |
1.1 |
|
| 42 |
1.1 |
|
| 43 |
1.1 |
|
| 44 |
1.1 |
|
| 46 |
1.1 2.2 |
|
| 47 |
1.1 |
|
| 52 |
1.1 |
|
| 59 |
1.1 |
|
| 60 |
1.1 |
|
| 61 |
1.1 |
|
| 62 |
1.1 |
|
| 63 |
1.1 |
|
| 66 |
1.1 |
|
| 68 |
1.1 |
|
| 71 |
1.1 |
|
| 72 |
1.1 2.2 |
|
| 73 |
1.1 |
|
| 76 |
1.1 |
|
| 77 |
1.1 |
|
| 78 |
1.1 |
|
| 81 |
1.1 2.2 |
|
| 86 |
1.1 |
|
| 88 |
1.1 |
|
| 91 |
1.1 |
|
| 93 |
1.1 |
|
| 97 |
1.1 |
|
| 98 |
1.1 |
|
| 99 |
1.1 |
|
| 102 |
1.1 2.2 |
|
| 105 |
1.1 |
|
| 110 |
1.1 2.2 |
|
| 112 |
1.1 |
|
| 116 |
1.1 2.2 |
|
| 117 |
1.1 |
|
| 118 |
1.1 2.2 |
|
| 124 |
1.1 2.2 |
|
| 125 |
1.1 2.2 |
|
| 126 |
1.1 2.2 |
|
| 127 |
1.1 2.2 |
|
| 129 |
1.1 |
|
| 133 |
1.1 |
|
| 137 |
1.1 2.2 |
|
| 153 |
1.1 2.2 |
|
| 161 |
1.1 2.2 |
|
| 187 |
1.1 |
|
| 189 |
1.1 |
|
| 195 |
1.1 |
|
| 203 |
1.1 |
|
| 204 |
1.1 |
|
| 206 |
1.1 |
|
| 210 |
1.1 |
|
| 216 |
1.1 |
|
| 217 |
1.1 |
|
| 219 |
1.1 2.2 |
|
| 223 |
1.1 |
|
| 224 |
1.1 |
|
| 225 |
1.1 |
|
| 226 |
1.1 |
|
| 227 |
1.1 |
|
| 228 |
1.1 |
|
| 229 |
1.1 |
|
| 230 |
1.1 |
|
| 231 |
1.1 |
|
| 232 |
1.1 |
|
| 233 |
1.1 |
|
| 234 |
1.1 |
|
| 235 |
1.1 |
|
| 236 |
1.1 |
|
| 237 |
1.1 |
|
| 238 |
1.1 |
|
| 239 |
1.1 |
|
| 240 |
1.1 |
|
| 241 |
1.1 |
|
| 246 |
1.1 |
|
| 254 |
1.1 |
|
| 259 |
1.1 |
|
| 263 |
1.1 2.2 |
|
| 267 |
1.1 |
|
| 270 |
1.1 |
|
| 276 |
1.1 2.2 3.3 |
|
| 282 |
1.1 |
|
| 294 |
1.1 |
|
| 307 |
1.1 |
|
| 311 |
1.1 |