| 1 | package com.github.valid8j.metamor; | |
| 2 | ||
| 3 | import com.github.valid8j.pcond.core.Evaluator; | |
| 4 | import com.github.valid8j.pcond.core.printable.PrintableFunction; | |
| 5 | import com.github.valid8j.pcond.forms.Printables; | |
| 6 | ||
| 7 | import java.util.function.Function; | |
| 8 | import java.util.function.IntFunction; | |
| 9 | ||
| 10 | import static java.util.Objects.requireNonNull; | |
| 11 | ||
| 12 | public interface IoContext<I, O> { | |
| 13 | String prefix(); | |
| 14 | ||
| 15 | default String name() { | |
| 16 |
1
1. name : replaced return value with "" for com/github/valid8j/metamor/IoContext::name → SURVIVED |
return this.prefix() + ":" + this.input().name() + "=>" + this.output().name(); |
| 17 | } | |
| 18 | ||
| 19 | Dataset<I> input(); | |
| 20 | ||
| 21 | Dataset<O> output(); | |
| 22 | ||
| 23 | enum Utils { | |
| 24 | ; | |
| 25 | ||
| 26 | public static <I, O> Function<Dataset<I>, Ongoing<I, O>> toContextFunction(String contextName, String outputContextName) { | |
| 27 |
2
1. lambda$toContextFunction$0 : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::lambda$toContextFunction$0 → KILLED 2. toContextFunction : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::toContextFunction → KILLED |
return Printables.function("begin:" + contextName, input -> new Ongoing.Impl<>(contextName, input, outputContextName)); |
| 28 | } | |
| 29 | ||
| 30 | public static <I, O> Function<Ongoing<I, O>, Ongoing<I, O>> toContextEndomorphicFunction(Function<IoContext<I, O>, Function<I, O>> mapper, int numItems, IntFunction<String> variableNameFormatter) { | |
| 31 | requireNonNull(mapper); | |
| 32 | Function<Ongoing<I, O>, Ongoing<I, O>> ret = null; | |
| 33 |
3
1. toContextEndomorphicFunction : Changed increment from 1 to -1 → TIMED_OUT 2. toContextEndomorphicFunction : changed conditional boundary → KILLED 3. toContextEndomorphicFunction : negated conditional → KILLED |
for (int i = 0; i < numItems; i++) { |
| 34 | Function<Ongoing<I, O>, Ongoing<I, O>> cur = mapperToEndomorphicProcessor(mapper, i, variableNameFormatter); | |
| 35 |
1
1. toContextEndomorphicFunction : negated conditional → KILLED |
if (ret == null) { |
| 36 | ret = cur; | |
| 37 | } else | |
| 38 | ret = ret.andThen(cur); | |
| 39 | } | |
| 40 | assert ret != null; | |
| 41 |
1
1. toContextEndomorphicFunction : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::toContextEndomorphicFunction → KILLED |
return ret; |
| 42 | } | |
| 43 | ||
| 44 | public static <I, O> Function<Ongoing<I, O>, Ongoing<I, O>> mapperToEndomorphicProcessor(Function<IoContext<I, O>, Function<I, O>> mapper, int i, IntFunction<String> variableNameFormatter) { | |
| 45 |
1
1. mapperToEndomorphicProcessor : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::mapperToEndomorphicProcessor → KILLED |
return getOngoingOngoingFunction(mapper, i, variableNameFormatter); |
| 46 | } | |
| 47 | ||
| 48 | private static <I, O> Function<Ongoing<I, O>, Ongoing<I, O>> getOngoingOngoingFunction(Function<IoContext<I, O>, Function<I, O>> mapper, int i, IntFunction<String> variableNameFormatter) { | |
| 49 |
1
1. getOngoingOngoingFunction : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::getOngoingOngoingFunction → KILLED |
return Printables.function( |
| 50 |
1
1. lambda$getOngoingOngoingFunction$1 : replaced return value with "" for com/github/valid8j/metamor/IoContext$Utils::lambda$getOngoingOngoingFunction$1 → SURVIVED |
() -> String.format("%s(%s)", mapper, variableNameFormatter.apply(i)), |
| 51 | c -> { | |
| 52 | I in = c.input().get(i); | |
| 53 | O out = mapper.apply(c).apply(in); | |
| 54 | c.output().add(out); | |
| 55 |
1
1. lambda$getOngoingOngoingFunction$2 : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::lambda$getOngoingOngoingFunction$2 → KILLED |
return c.cloneObject(); |
| 56 | }); | |
| 57 | } | |
| 58 | ||
| 59 | public static <I, O> Function<Ongoing<I, O>, IoContext<I, O>> toCloseFunction(String contextName) { | |
| 60 | // close | |
| 61 |
2
1. lambda$toCloseFunction$3 : replaced return value with "" for com/github/valid8j/metamor/IoContext$Utils::lambda$toCloseFunction$3 → SURVIVED 2. toCloseFunction : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::toCloseFunction → KILLED |
return ((PrintableFunction<Ongoing<I, O>, IoContext<I, O>>) Printables.<Ongoing<I, O>, IoContext<I, O>>function(() -> "end:" + contextName, Ongoing::close)).markSquashable(); |
| 62 | } | |
| 63 | ||
| 64 | public static <I, O> Function<IoContext<I, O>, Dataset<O>> toOutputExtractorFunction(String contextName) { | |
| 65 |
2
1. lambda$toOutputExtractorFunction$4 : replaced return value with "" for com/github/valid8j/metamor/IoContext$Utils::lambda$toOutputExtractorFunction$4 → SURVIVED 2. toOutputExtractorFunction : replaced return value with null for com/github/valid8j/metamor/IoContext$Utils::toOutputExtractorFunction → KILLED |
return Printables.function(() -> "output(" + contextName + ")", IoContext::output); |
| 66 | } | |
| 67 | } | |
| 68 | ||
| 69 | interface Closed<I, O> extends IoContext<I, O> { | |
| 70 | class Impl<I, O> implements Closed<I, O> { | |
| 71 | private final Dataset<I> input; | |
| 72 | private final Dataset<O> output; | |
| 73 | private final String prefix; | |
| 74 | ||
| 75 | public Impl(String prefix, Dataset<I> input, Dataset<O> output) { | |
| 76 | this.prefix = prefix; | |
| 77 | this.input = input; | |
| 78 | this.output = output; | |
| 79 | } | |
| 80 | ||
| 81 | @Override | |
| 82 | public String prefix() { | |
| 83 |
1
1. prefix : replaced return value with "" for com/github/valid8j/metamor/IoContext$Closed$Impl::prefix → SURVIVED |
return this.prefix; |
| 84 | } | |
| 85 | ||
| 86 | @Override | |
| 87 | public Dataset<I> input() { | |
| 88 |
1
1. input : replaced return value with null for com/github/valid8j/metamor/IoContext$Closed$Impl::input → KILLED |
return input; |
| 89 | } | |
| 90 | ||
| 91 | @Override | |
| 92 | public Dataset<O> output() { | |
| 93 |
1
1. output : replaced return value with null for com/github/valid8j/metamor/IoContext$Closed$Impl::output → KILLED |
return output; |
| 94 | } | |
| 95 | ||
| 96 | ||
| 97 | @Override | |
| 98 | public String toString() { | |
| 99 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/IoContext$Closed$Impl::toString → SURVIVED |
return "(context:" + name() + ")"; |
| 100 | } | |
| 101 | } | |
| 102 | } | |
| 103 | ||
| 104 | interface Ongoing<I, O> extends IoContext<I, O>, Evaluator.Snapshottable { | |
| 105 | @Override | |
| 106 | Dataset.OnGoing<O> output(); | |
| 107 | ||
| 108 | default Ongoing<I, O> cloneObject() { | |
| 109 |
1
1. cloneObject : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing::cloneObject → KILLED |
return new Impl<>(this.prefix(), input(), output()); |
| 110 | } | |
| 111 | ||
| 112 | default IoContext<I, O> close() { | |
| 113 |
1
1. close : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing::close → KILLED |
return new Closed.Impl<>(this.prefix(), this.input(), this.output().close()); |
| 114 | } | |
| 115 | ||
| 116 | class Snapshot { | |
| 117 | final private Object in; | |
| 118 | final private Object out; | |
| 119 | ||
| 120 | public Snapshot(Object in, Object out) { | |
| 121 | this.in = in; | |
| 122 | this.out = out; | |
| 123 | } | |
| 124 | ||
| 125 | public Object in() { | |
| 126 |
1
1. in : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing$Snapshot::in → SURVIVED |
return this.in; |
| 127 | } | |
| 128 | ||
| 129 | public Object out() { | |
| 130 |
1
1. out : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing$Snapshot::out → SURVIVED |
return this.out; |
| 131 | } | |
| 132 | ||
| 133 | public String toString() { | |
| 134 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/IoContext$Ongoing$Snapshot::toString → NO_COVERAGE |
return String.format("%s=>%s", this.in, this.out); |
| 135 | } | |
| 136 | } | |
| 137 | ||
| 138 | class Impl<I, O> implements Ongoing<I, O> { | |
| 139 | private final String prefix; | |
| 140 | private final Dataset<I> input; | |
| 141 | private final Dataset.OnGoing<O> output; | |
| 142 | ||
| 143 | public Impl(String prefix, Dataset<I> input, String outputDatasetName) { | |
| 144 | this.prefix = prefix; | |
| 145 | this.input = requireNonNull(input); | |
| 146 | this.output = new Dataset.OnGoing.Impl<>(outputDatasetName); | |
| 147 | } | |
| 148 | ||
| 149 | public Impl(String prefix, Dataset<I> input, Dataset<O> output) { | |
| 150 | this.prefix = prefix; | |
| 151 | this.input = requireNonNull(input); | |
| 152 | this.output = new Dataset.OnGoing.Impl<>(output.name(), output); | |
| 153 | } | |
| 154 | ||
| 155 | @Override | |
| 156 | public String prefix() { | |
| 157 |
1
1. prefix : replaced return value with "" for com/github/valid8j/metamor/IoContext$Ongoing$Impl::prefix → SURVIVED |
return this.prefix; |
| 158 | } | |
| 159 | ||
| 160 | @Override | |
| 161 | public Dataset<I> input() { | |
| 162 |
1
1. input : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing$Impl::input → KILLED |
return this.input; |
| 163 | } | |
| 164 | ||
| 165 | @Override | |
| 166 | public Dataset.OnGoing<O> output() { | |
| 167 | assert this.output != null; | |
| 168 |
1
1. output : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing$Impl::output → KILLED |
return this.output; |
| 169 | } | |
| 170 | ||
| 171 | @Override | |
| 172 | public Object snapshot() { | |
| 173 |
1
1. snapshot : negated conditional → KILLED |
if (this.output.size() == 0) |
| 174 |
1
1. snapshot : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing$Impl::snapshot → SURVIVED |
return new Object() { |
| 175 | @Override | |
| 176 | public String toString() { | |
| 177 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/IoContext$Ongoing$Impl$1::toString → SURVIVED |
return String.format("(context:%s)", Impl.this.name()); |
| 178 | } | |
| 179 | }; | |
| 180 |
2
1. snapshot : replaced return value with null for com/github/valid8j/metamor/IoContext$Ongoing$Impl::snapshot → SURVIVED 2. snapshot : Replaced integer subtraction with addition → KILLED |
return new Snapshot(this.input.get(this.output.size() - 1), this.output.last()); |
| 181 | } | |
| 182 | ||
| 183 | @Override | |
| 184 | public String toString() { | |
| 185 |
1
1. toString : negated conditional → KILLED |
if (this.output.size() == 0) |
| 186 |
1
1. toString : replaced return value with "" for com/github/valid8j/metamor/IoContext$Ongoing$Impl::toString → SURVIVED |
return "(empty)"; |
| 187 |
2
1. toString : replaced return value with "" for com/github/valid8j/metamor/IoContext$Ongoing$Impl::toString → SURVIVED 2. toString : Replaced integer subtraction with addition → KILLED |
return String.format("in: <%s>%nout:<%s>", this.input.get(this.output.size() - 1), this.output.last()); |
| 188 | } | |
| 189 | } | |
| 190 | } | |
| 191 | } | |
Mutations | ||
| 16 |
1.1 |
|
| 27 |
1.1 2.2 |
|
| 33 |
1.1 2.2 3.3 |
|
| 35 |
1.1 |
|
| 41 |
1.1 |
|
| 45 |
1.1 |
|
| 49 |
1.1 |
|
| 50 |
1.1 |
|
| 55 |
1.1 |
|
| 61 |
1.1 2.2 |
|
| 65 |
1.1 2.2 |
|
| 83 |
1.1 |
|
| 88 |
1.1 |
|
| 93 |
1.1 |
|
| 99 |
1.1 |
|
| 109 |
1.1 |
|
| 113 |
1.1 |
|
| 126 |
1.1 |
|
| 130 |
1.1 |
|
| 134 |
1.1 |
|
| 157 |
1.1 |
|
| 162 |
1.1 |
|
| 168 |
1.1 |
|
| 173 |
1.1 |
|
| 174 |
1.1 |
|
| 177 |
1.1 |
|
| 180 |
1.1 2.2 |
|
| 185 |
1.1 |
|
| 186 |
1.1 |
|
| 187 |
1.1 2.2 |