CurriedContextUtils.java

1
package com.github.dakusui.pcond.experimentals.currying.context;
2
3
import com.github.dakusui.pcond.experimentals.currying.CurriedFunction;
4
import com.github.dakusui.pcond.experimentals.currying.CurryingUtils;
5
import com.github.dakusui.pcond.core.printable.PrintablePredicateFactory;
6
import com.github.dakusui.pcond.forms.Predicates;
7
8
import java.util.Arrays;
9
import java.util.Collection;
10
import java.util.List;
11
import java.util.function.Function;
12
import java.util.function.Predicate;
13
import java.util.stream.Stream;
14
15
import static java.util.Arrays.asList;
16
import static java.util.Objects.requireNonNull;
17
18
/**
19
 * A utility class that collects helper methods for the "Context" mechanism.
20
 */
21
public enum CurriedContextUtils {
22
  ;
23
24
  public static Stream<CurriedContext> nest(Stream<?> stream, Collection<?> inner) {
25 1 1. nest : replaced return value with Stream.empty for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::nest → KILLED
    return toCurriedContextStream(stream)
26 1 1. lambda$nest$0 : replaced return value with Stream.empty for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$nest$0 → KILLED
        .flatMap((CurriedContext curriedContext) -> inner
27
            .stream()
28
            .map((Function<Object, CurriedContext>) curriedContext::append));
29
  }
30
31
  public static Stream<CurriedContext> toCurriedContextStream(Stream<?> stream) {
32 1 1. toCurriedContextStream : replaced return value with Stream.empty for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::toCurriedContextStream → KILLED
    return stream.map(CurriedContextUtils::toCurriedContext);
33
  }
34
35
  public static <T> CurriedContext toCurriedContext(T t) {
36 2 1. toCurriedContext : negated conditional → KILLED
2. toCurriedContext : replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::toCurriedContext → KILLED
    return t instanceof CurriedContext ? (CurriedContext) t : CurriedContext.from(t);
37
  }
38
39
  public static <R> Predicate<CurriedContext> applyAndTest(CurriedFunction<Object, Object> curriedFunction, Predicate<? super R> pred, @SuppressWarnings("SameParameterValue") Class<? extends R> type, int... orderArgs) {
40
    List<Object> spec = asList(curriedFunction, pred, asList(Arrays.stream(orderArgs).boxed().toArray()));
41 1 1. applyAndTest : replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::applyAndTest → KILLED
    return PrintablePredicateFactory.parameterizedLeaf(
42 5 1. lambda$applyAndTest$2 : replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$applyAndTest$2 → KILLED
2. lambda$applyAndTest$4 : replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$applyAndTest$4 → KILLED
3. lambda$null$1 : replaced return value with "" for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$null$1 → KILLED
4. lambda$null$3 : replaced boolean return with false for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$null$3 → KILLED
5. lambda$null$3 : replaced boolean return with true for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$null$3 → KILLED
        args -> () -> String.format("%s(%s%s)", args.get(1), args.get(0), args.get(2)), args -> (CurriedContext curriedContext) -> (pred).test(type.cast(CurryingUtils.applyCurriedFunction(curriedFunction, orderArgs).apply(curriedContext))), spec, CurriedContextUtils.class
43
    );
44
  }
45
46
  public static Predicate<CurriedContext> toContextPredicate(CurriedFunction<Object, Object> curriedFunction, int... orderArgs) {
47 1 1. toContextPredicate : replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::toContextPredicate → KILLED
    return CurriedContextUtils.applyAndTest(curriedFunction, createPredicate("curry", Predicates.isTrue()), Boolean.class, orderArgs);
48
  }
49
50
  public static <T> Predicate<T> createPredicate(String s, Predicate<T> predicate) {
51
    requireNonNull(s);
52 2 1. createPredicate : replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::createPredicate → KILLED
2. lambda$createPredicate$5 : replaced return value with "" for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$createPredicate$5 → KILLED
    return PrintablePredicateFactory.leaf(() -> s, predicate, CurriedContextUtils.class);
53
  }
54
}

Mutations

25

1.1
Location : nest
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello3(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with Stream.empty for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::nest → KILLED

26

1.1
Location : lambda$nest$0
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello3(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with Stream.empty for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$nest$0 → KILLED

32

1.1
Location : toCurriedContextStream
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello3(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with Stream.empty for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::toCurriedContextStream → KILLED

36

1.1
Location : toCurriedContext
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.givenStreamOfSingleString$hello$_whenRequireNonNullIsFound_thenPassing(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
negated conditional → KILLED

2.2
Location : toCurriedContext
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.givenStreamOfSingleString$hello$_whenRequireNonNullIsFound_thenPassing(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::toCurriedContext → KILLED

41

1.1
Location : applyAndTest
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::applyAndTest → KILLED

42

1.1
Location : lambda$applyAndTest$2
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$applyAndTest$2 → KILLED

2.2
Location : lambda$applyAndTest$4
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$applyAndTest$4 → KILLED

3.3
Location : lambda$null$1
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.given$hello$_$world$_whenRequireNestedStreamImpossibleConditions_thenPreconditionViolationExceptionWithCorrectMessage(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with "" for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$null$1 → KILLED

4.4
Location : lambda$null$3
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced boolean return with false for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$null$3 → KILLED

5.5
Location : lambda$null$3
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello_b(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced boolean return with true for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$null$3 → KILLED

47

1.1
Location : toContextPredicate
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::toContextPredicate → KILLED

52

1.1
Location : createPredicate
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.hello_b(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::createPredicate → KILLED

2.2
Location : lambda$createPredicate$5
Killed by : com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest.given$hello$_$world$_whenRequireNestedStreamImpossibleConditions_thenPreconditionViolationExceptionWithCorrectMessage(com.github.dakusui.pcond.experimentals.DbCCurriedFunctionsTest)
replaced return value with "" for com/github/dakusui/pcond/experimentals/currying/context/CurriedContextUtils::lambda$createPredicate$5 → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3