• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / learnlib / 13034511199

29 Jan 2025 03:18PM UTC coverage: 94.304% (-0.09%) from 94.389%
13034511199

push

github

mtf90
spmm: improve assertions

2 of 2 new or added lines in 1 file covered. (100.0%)

24 existing lines in 7 files now uncovered.

12417 of 13167 relevant lines covered (94.3%)

1.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of LearnLib <https://learnlib.de>.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package de.learnlib.oracle.equivalence.sba;
17

18
import java.util.Collection;
19
import java.util.stream.Stream;
20

21
import de.learnlib.oracle.MembershipOracle;
22
import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle;
23
import net.automatalib.alphabet.ProceduralInputAlphabet;
24
import net.automatalib.automaton.concept.FiniteRepresentation;
25
import net.automatalib.automaton.procedural.SBA;
26
import net.automatalib.common.util.collection.IteratorUtil;
27
import net.automatalib.util.automaton.conformance.SBAWMethodTestsIterator;
28
import net.automatalib.util.automaton.conformance.WMethodTestsIterator;
29
import net.automatalib.word.Word;
30

31
/**
32
 * An {@link SBA} version of {@link de.learnlib.oracle.equivalence.WMethodEQOracle} which generates test sequences based
33
 * on the {@link SBAWMethodTestsIterator W-method} for each procedure.
34
 *
35
 * @param <I>
36
 *         input symbol type
37
 */
38
public class WMethodEQOracle<I> extends AbstractTestWordEQOracle<SBA<?, I>, I, Boolean> {
39

40
    private final int lookahead;
41
    private final int expectedSize;
42

43
    /**
44
     * Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int)} that sets {@code lookahead}
45
     * to 1.
46
     *
47
     * @param sulOracle
48
     *         interface to the system under learning
49
     */
50
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle) {
UNCOV
51
        this(sulOracle, 1);
×
UNCOV
52
    }
×
53

54
    /**
55
     * Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int)} that sets
56
     * {@code expectedSize} to 0.
57
     *
58
     * @param sulOracle
59
     *         interface to the system under learning
60
     * @param lookahead
61
     *         the maximum length of the "middle" part of the test cases
62
     */
63
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead) {
64
        this(sulOracle, lookahead, 0);
2✔
65
    }
2✔
66

67
    /**
68
     * Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int, int)} that sets
69
     * {@code batchSize} to 1.
70
     *
71
     * @param sulOracle
72
     *         interface to the system under learning
73
     * @param lookahead
74
     *         the (minimal) maximum length of the "middle" part of the test cases
75
     * @param expectedSize
76
     *         the expected size of the system under learning
77
     */
78
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead, int expectedSize) {
79
        this(sulOracle, lookahead, expectedSize, 1);
2✔
80
    }
2✔
81

82
    /**
83
     * Constructor. Uses
84
     * {@link Math#max(int, int) Math.max}{@code (lookahead, expectedSize - }{@link FiniteRepresentation#size()
85
     * hypothesis.size()}{@code )} to determine the maximum length of sequences, that should be appended to the
86
     * transition-cover part of the test sequence to account for the fact that the system under learning may have more
87
     * states than the current hypothesis.
88
     *
89
     * @param sulOracle
90
     *         interface to the system under learning
91
     * @param lookahead
92
     *         the (minimal) maximum length of the "middle" part of the test cases
93
     * @param expectedSize
94
     *         the expected size of the system under learning
95
     * @param batchSize
96
     *         size of the batches sent to the membership oracle
97
     *
98
     * @see WMethodTestsIterator
99
     */
100
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead, int expectedSize, int batchSize) {
101
        super(sulOracle, batchSize);
2✔
102
        this.lookahead = lookahead;
2✔
103
        this.expectedSize = expectedSize;
2✔
104
    }
2✔
105

106
    @Override
107
    protected Stream<Word<I>> generateTestWords(SBA<?, I> hypothesis, Collection<? extends I> inputs) {
108
        if (!(inputs instanceof ProceduralInputAlphabet)) {
2✔
UNCOV
109
            throw new IllegalArgumentException("Inputs are not a procedural alphabet");
×
110
        }
111

112
        @SuppressWarnings("unchecked")
113
        final ProceduralInputAlphabet<I> alphabet = (ProceduralInputAlphabet<I>) inputs;
2✔
114

115
        return IteratorUtil.stream(new SBAWMethodTestsIterator<>(hypothesis,
2✔
116
                                                                 alphabet,
117
                                                                 Math.max(lookahead,
2✔
118
                                                                          expectedSize - hypothesis.size())));
2✔
119
    }
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc