• 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/spmm/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.spmm;
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.automaton.procedural.SPMM;
27
import net.automatalib.common.util.collection.IteratorUtil;
28
import net.automatalib.util.automaton.conformance.SPMMWMethodTestsIterator;
29
import net.automatalib.util.automaton.conformance.WMethodTestsIterator;
30
import net.automatalib.word.Word;
31

32
/**
33
 * Implements an equivalence test by applying the W-method test on the procedures of the given hypothesis {@link SBA},
34
 * as described in "Testing software design modeled by finite state machines" by T.S. Chow.
35
 *
36
 * @param <I>
37
 *         input symbol type
38
 */
39
public class WMethodEQOracle<I, O> extends AbstractTestWordEQOracle<SPMM<?, I, ?, O>, I, Word<O>> {
40

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

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

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

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

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

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

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

116
        return IteratorUtil.stream(new SPMMWMethodTestsIterator<>(hypothesis,
2✔
117
                                                                  alphabet,
118
                                                                  Math.max(lookahead,
2✔
119
                                                                           expectedSize - hypothesis.size())));
2✔
120
    }
121
}
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